![](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiSTnOdF4plj2Ne7pm8JUzm0kVacSHdQRzcTYDs8M0i0QNtWWAHp53YukUc09eJtx28ArcWvLZ6qPhkGY_eHvEM51Qje0twClvrnALPp5rYKnWUgbjDazXj4YHShaSL4c40rEWZuqNqsKfh/s320/dog_tif.jpg)
The Solution: A Linux Live CD with Python pre-installed; an external storage device; this Python script:
#!/usr/bin/python
# Filename: backup.py
import os, time
source = ['DIRECTORY OF WINDOWS FILES TO BE BACKED-UP!’]
target_dir = 'LOCATION OF EXTERNAL STORAGE DEVICE!'
today = target_dir + time.strftime('%Y%m%d')
now = time.strftime('%H%M%S')
comment = raw_input('Enter a comment --> ')
if len(comment) == 0:
target = today + os.sep + now + '.zip'
else:
target = today + os.sep + now + '_' + \
comment.replace(' ', '_') + '.zip'
if not os.path.exists(today):
os.mkdir(today) # make directory
print 'Successfully created directory', today
zip_command = "zip -qr '%s' %s" % (target, ' '.join(source))
if os.system(zip_command) == 0:
print 'Successful backup to', target
else:
print 'Backup FAILED'
No comments
Post a Comment