< ^ txt
Sat Jan 31 11:17:09 EST 2015
Went to bed around 11:30 last night. Woke up around 8 this morning. Slept OK.
Finished the day with a couple of Griffin Claw brewery's Norm's Raggedy Ass IPA.
UFS filesystem snapshots look interesting. https://www.freebsd.org/doc/handbook/snapshots.html
Goals:
- Help mom set up new Roku
Done.
- Replace driver-side wiper arm
Done.
- Finish backup script
Done. See below.
Questions:
- Is there a emacs-style keystroke (ctrl-something) in bash/readline that does incremental history search like up arrow?
Yes. Ctl-R, and keep hitting ctrl-r to step back through matching history.
#!/usr/bin/env python
# backupexternal
#
# A Python script to back up files to an external hard drive.
#
# This file should be run manually by the user. A companion script (backupcheck)
# checks the age of the last backup, and nags the user when appropriate.
#
# Paul Gorman, 30 January 2015
import subprocess
import re
import sys
home = '/home/paulgorman'
lastBackupFile = home + '/.lastbackup'
backupDiskMountPoint = '/backup/mnt/'
# Mount the right media or die:
backupDisk = re.compile( r'.*c391bdc8-1d0a-4fd6-8a54-6b575960261b.*sdc1')
disks = subprocess.check_output(['ls', '-la', '/dev/disk/by-uuid/'])
if backupDisk.search(disks):
subprocess.check_call(['mount', '/dev/sdc1', backupDiskMountPoint])
else:
sys.exit("Error. Could not find backup disk. Did you turn it on?")
toBackUp = [
home,
'/root',
'/data',
'/etc',
]
toExclude = [
home + '/tmp',
home + '/Downloads',
]
try:
rsyncCommand = 'rsync -aqh'
for e in toExclude:
rsyncCommand = rsyncCommand + ' --exclude ' + e
for b in toBackUp:
rsyncCommand = rsyncCommand + ' ' + b
rsyncCommand = rsyncCommand + ' ' + backupDiskMountPoint
subprocess.check_call(rsyncCommand, shell=True)
except:
subprocess.check_call(['umount', backupDiskMountPoint])
raise
subprocess.check_call(['umount', backupDiskMountPoint])
now = subprocess.check_output(['date', '+%s'])
f = open(lastBackupFile, 'w')
f.write(now)
f.close
< ^ txt