Skip to content

Instantly share code, notes, and snippets.

@northox
Created January 6, 2016 23:14
Show Gist options
  • Save northox/90f4973ec18df2162319 to your computer and use it in GitHub Desktop.
Save northox/90f4973ec18df2162319 to your computer and use it in GitHub Desktop.
Single click backup of QubesOS
#!/usr/bin/env python
#
# Single click backup of QubesOS - beacause, really, there's no need to protect
# the password in dom0. If it's ever accessed, it was already game over.
#
# Author: Danny Fullerton - Mantor Organization
#
# Usage
# - Mod commands accordingly, e.g. filesystem, path, drive
# - Create a file in dom0:~/.backup.pass containing your password.
# - Create an AppVM called backup and assign the usb drive to it
#
import pexpect
PASSWD_FILE = '~/.backup.pass'
LOG = '~/backup.log'
rawlist = pexpect.run("qvm-ls --raw-list")
#rawlist = "dom0\nwork-devel"
bkp_cmd = "qvm-backup -d backup -e -z /mnt/removable/backor/qubes/ -x backup " + rawlist
mount_cmd = "qvm-run -a -u root backup 'mount -t ntfs-3g -o rw,realatime,uid=1000,gid=1000,umask=133,dmask=022 /dev/xvdi1 /mnt/removable'"
###
passwd = open(PASSWD_FILE, 'r').readline().rstrip()
pexpect.run(mount_cmd)
child = pexpect.spawn(bkp_cmd)
child.logfile = open(LOG, 'w')
child.expect('y/N')
child.sendline('y')
child.expect('enter the pass phrase')
child.sendline(passwd)
child.expect('again for verification')
child.sendline(passwd)
child.interact()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment