Skip to content

Instantly share code, notes, and snippets.

@oker1
Created November 1, 2011 12:31
Show Gist options
  • Save oker1/1330421 to your computer and use it in GitHub Desktop.
Save oker1/1330421 to your computer and use it in GitHub Desktop.
linux desktop backup
#!/bin/bash
set -e
#cryptsetup luksFormat -c aes-ecb-plain -s 128
#open, mount
cryptsetup luksOpen /dev/disk/by-uuid/e0f51d72-1331-4663-a4ac-281cacdbe691 backup
mount /media/backup
#backups
#mbr
dd if=/dev/sda of=/media/backup/sda-mbr.bin bs=512 count=1
#lvm snapshot of system
lvcreate -l100%FREE -s -n root-backup /dev/wd15/root
dd if=/dev/wd15/root-backup of=/media/backup/ubuntu.img
lvremove -f /dev/wd15/root-backup
#rsnapshot non-system data
rsnapshot -v daily
#umount, close
umount /media/backup
cryptsetup luksClose /dev/mapper/backup
#poweroff
DEV=`blkid | grep abf0f360-6e96-4df4-b500-a70898ab5a72 | awk -F: '{ print $1; }'`
DEV=${DEV:5:3}
echo 1 > /sys/block/$DEV/device/delete
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment