Created
May 18, 2016 08:37
-
-
Save TinoDidriksen/d5b3acd0e46a8386908a270f27ac286b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
vshadow.exe -q | grep SNAP | perl -wpne 'chomp; s/^.*(\{[^}]+\}).*$/$1/; print `vshadow -ds=$_`; $_ = "";' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
export TARGET=second | |
echo "Backing up to $TARGET ..." | |
export BHOST=root@remote-host.com | |
cd /tmp | |
rm -fv last.txt | |
ssh $BHOST 'umount -v /mnt/second' | |
ssh $BHOST 'cryptsetup -v luksClose backup_crypt' | |
echo -e "ENCRYPTION KEY GOES HERE" | ssh $BHOST 'cryptsetup -v luksOpen /dev/sdb2 backup_crypt && mount -v -t btrfs -onoatime,compress-force=zlib /dev/mapper/backup_crypt /mnt/second' | |
DATE=$(date -u '+%Y%m%d-%H%M') | |
ssh $BHOST "cd /mnt/second && ls -1 | grep backup- | sort -r | sed 1,120d | xargs -r -n1 btrfs subvolume delete && cd /tmp" | |
ssh $BHOST "cd /mnt/second && btrfs subvolume snapshot latest backup-$DATE && cd /tmp" | |
rsync -avz --timeout=10 $BHOST:/mnt/$TARGET/last.txt ./ | |
if [ ! -f last.txt ] | |
then | |
echo "Could not fetch $TARGET/last.txt - giving up." | |
exit | |
fi | |
. ~/bin/backup-helper.sh | |
ssh $BHOST 'umount -v /mnt/second && cryptsetup -v luksClose backup_crypt' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
echo "Backing up to $BHOST ..." | |
~/bin/wipe-shadows.sh | |
export SID=$(vshadow -nw -p C: 2>&1 | grep SNAPSHOT | perl -wpne 's/^.*(\{.+\}).*$/$1/;') | |
echo "GUID $SID" | |
vshadow "-el=$SID,Z:" | |
test -e /cygdrive/z && cd /cygdrive/z || cd /cygdrive/c | |
rsync -e 'ssh -4' -rltHDvz --partial --ignore-errors \ | |
--exclude="*.tmp" \ | |
--exclude="*.img" \ | |
--exclude="*.msi" \ | |
--exclude="*.msp" \ | |
--exclude="**/*[Cc]ache*/**" \ | |
--exclude="**/thumbnails/**" \ | |
--exclude="**/[Tt]emporary/**" \ | |
--exclude="**/[Tt]emp/**" \ | |
--exclude="**/.minecraft/assets/**" \ | |
--exclude="**/Temporary Internet Files/**" \ | |
--exclude="**/.android*" \ | |
--exclude="**/.AndroidStudio*" \ | |
--delete-excluded --delete --inplace $@ Users $BHOST:/mnt/$TARGET/latest/LenovoZ710/ | |
rsync -e 'ssh -4' -rltHDvz --partial --ignore-errors \ | |
--exclude="**/Debug/**" \ | |
--exclude="**/Release/**" \ | |
--exclude="**/Dropbox/**/*.mp4" \ | |
--exclude="**/Dropbox/Books/**" \ | |
--exclude="**/.dropbox*" \ | |
--exclude="*.tmp" \ | |
--exclude="*.msi" \ | |
--exclude="*.msp" \ | |
--exclude="*.cab" \ | |
--exclude="*.iso" \ | |
--exclude="*.sdf" \ | |
--exclude="*.pdb" \ | |
--delete --delete-excluded --inplace $@ Documents $BHOST:/mnt/$TARGET/latest/LenovoZ710/ | |
rsync -e 'ssh -4' -rltHDvz --partial --ignore-errors \ | |
--exclude="**/Debug/**" \ | |
--exclude="**/Release/**" \ | |
--exclude="*.sdf" \ | |
--exclude="*.pdb" \ | |
--delete --delete-excluded --inplace $@ Cygwin $BHOST:/mnt/$TARGET/latest/LenovoZ710/ | |
rsync -e 'ssh -4' -rltHDvz --partial --ignore-errors --delete --delete-excluded --inplace $@ Applications \ | |
--exclude="**/Android/**" \ | |
--exclude="**/Qt*/**" \ | |
$BHOST:/mnt/$TARGET/latest/LenovoZ710/ | |
#rsync -e 'ssh -4' -rltHDvz --partial --ignore-errors --delete --inplace $@ Program\ Files* $BHOST:/mnt/$TARGET/latest/LenovoZ710/ | |
rsync -e 'ssh -4' -rltHDvz --partial --ignore-errors \ | |
--exclude="*.msi" \ | |
--exclude="*.tmp" \ | |
--exclude="*.msp" \ | |
--exclude="**/MEMORY.DMP" \ | |
--exclude="**/Installer/**" \ | |
--exclude="**/servicing/**" \ | |
--exclude="**/SysWOW64/**" \ | |
--exclude="**/System32/**" \ | |
--exclude="**/winsxs/**" \ | |
--exclude="**/WinSxS/**" \ | |
--exclude="**/WinStore/**" \ | |
--exclude="**/Temp/**" \ | |
--exclude="**/assembly/**" \ | |
--exclude="**/Microsoft.NET/**" \ | |
--exclude="**/SoftwareDistribution/**" \ | |
--exclude="**/ServiceProfiles/**" \ | |
--exclude="**/symbols/**" \ | |
--exclude="**/Prefetch/**" \ | |
--exclude="**/Speech/**" \ | |
--exclude="**/IME/**" \ | |
--exclude="**/Help/**" \ | |
--delete-excluded --delete --inplace $@ Windows $BHOST:/mnt/$TARGET/latest/LenovoZ710/ | |
rsync -e 'ssh -4' -rltHDvz -P --ignore-errors \ | |
--include="*/" \ | |
--include="*[Ss][Aa][Vv][Ee]*" \ | |
--include="Master/**" \ | |
--include="Settlers*/**" \ | |
--include="OpenTTD/**.png" \ | |
--include="*.sav" \ | |
--include="World of Warcraft/Logs*/**" \ | |
--include="World of Warcraft/Screenshots/**" \ | |
--include="World of Warcraft/Interface/**" \ | |
--include="World of Warcraft/WTF/**" \ | |
--exclude="*" \ | |
--delete-excluded --delete --inplace $@ Games $BHOST:/mnt/$TARGET/latest/LenovoZ710/ | |
rsync -e 'ssh -4' -rltHDvz -P --ignore-errors \ | |
--exclude="Apertium*.vdi" \ | |
--exclude="Apertium*.zip" \ | |
--exclude="Apertium*.7z" \ | |
--exclude="Apertium*.tmp" \ | |
--exclude="* Swap.vdi" \ | |
--exclude="*Windows 10*" \ | |
--exclude="*Alpha*" \ | |
--exclude="**/*.sav" \ | |
--delete-excluded --delete --inplace $@ Virtuals $BHOST:/mnt/$TARGET/latest/LenovoZ710/ | |
cd / | |
vshadow "-ds=$SID" | |
~/bin/wipe-shadows.sh |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment