Header-Panorama

My computer carries a somewhat peculiar configuration: An SSD with the operating system and home partition, and a regular HD for everything else. Living a in a world, where data matters, I therefore wrote this little script, to backup my home drive to an encrypted veracrypt container on the large normal HD in one command (in principle you could also just cron it). While not useful to prevent the loss of data if the laptop is lost entirely, it is a really nice way to quickly backup my stuff even when not online.

I jsut put the script here as-is, maybe it is useful to you. Use at your own risk.


#!/bin/bash
mountpath="/media/veracrypt_backup_$USER"

#This is where I will mount the backup container for $USER, which is located in /media/extra_home/backup/ under the username.
#Mount it
veracrypt -t -k "" --protect-hidden=no /media/extra_home/backup/$USER $mountpath/

#Do the background (nice/ionice) transfer of the data using rsync (simple clone, no versioning, but that is up to you)

# first HOME
nice -n19 ionice -c2 -n7 rsync -ravPm $1 --update --delete --modify-window=1  --exclude='.cache/' --exclude='.local/share/Trash' --exclude='.thumbnails/' --exclude='temp/' --exclude='*.tmp' --exclude='*~' --include='*/' --include=*  $HOME/ $mountpath/home

#And the /etc folder as well
nice -n19 ionice -c2 -n7 rsync -ravPm  $1 --delete --modify-window=1 --include='*/' --include=*  /etc/ $mountpath/etc

# unmount
veracrypt -d $mountpath

 


 

We use cookies

We use cookies on our website. Some of them are essential for the operation of the site, while others help us to improve this site and the user experience (tracking cookies). You can decide for yourself whether you want to allow cookies or not. Please note that if you reject them, you may not be able to use all the functionalities of the site.