Contact
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutSign UpSign In
| Download
Views: 39598
1
#!/usr/bin/env python
2
3
"""
4
Delete all the .tar.lz4 files from the /backups/project-id/ directories.
5
6
This is not a simple rm */*.tar.lz4, since there are way too many directories, and rm will die.
7
8
"""
9
10
import os, time
11
12
print "Getting directory listing..."
13
projects = os.listdir('/backups')
14
print "Got %s directories"%len(projects)
15
16
t = time.time()
17
i = 0
18
for project_id in projects:
19
path = '/backups/%s'%project_id
20
i += 1
21
eta = ((time.time() - t)/i * (len(projects)-i))/60
22
print "%s/%s: %s (%s minutes left)"%(i,len(projects), path, eta)
23
for X in os.listdir(path):
24
if X.endswith('.tar.lz4'):
25
os.unlink(path+'/'+X)
26
27