From f07a4a2c90e65351d262aaae0ec90f9725fed293 Mon Sep 17 00:00:00 2001 From: David Runge Date: Tue, 27 Oct 2015 11:05:40 +0100 Subject: bin/crypted-backups: Adding function for mirroring the backup locally or remotely. Adding TODO for recall function. Adding setting for irssi backup. --- bin/crypted-backups | 70 ++++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 69 insertions(+), 1 deletion(-) diff --git a/bin/crypted-backups b/bin/crypted-backups index d96ad36..5883c5c 100755 --- a/bin/crypted-backups +++ b/bin/crypted-backups @@ -354,12 +354,74 @@ function cleanup_backup () { return 0 } +function check_mirror_settings () { + if [ $mirror_host = "" -o $mirror_host = "127.0.0.1" -o $mirror_host = "localhost" ];then + "check_"$user_mode"_directory" $mirror_source + echo "local" + return 0 + else + if [ $mirror_user = "" ];then + echo "The \"mirror_user\" variable can not be empty if using a remote mirror!" + return 1 + fi + echo "remote" + return 0 + fi +} + +function mirror_backup () { + local mirror_source=$(sanitize_pathname $mirror_source) + local mirror_destination=$mirror_destination + local mirror_type=$(check_mirror_settings) + check_directory_exists $mirror_source + if [ $mirror_type = "local" ];then + rsync -r \ + -t \ + -p \ + -o \ + -g \ + -v \ + --progress\ + --delete\ + --ignore-existing\ + --size-only\ + -s \ + --exclude 'lost+found' \ + --exclude '.Trash-1000' \ + --exclude '$RECYCLEBIN' \ + --exclude 'System Volume Information' \ + --exclude '.thumbs' \ + $mirror_source \ + $mirror_destination + elif [ $mirror_type = "remote" ];then + rsync -r \ + -t \ + -p \ + -o \ + -g \ + -v \ + --progress\ + --delete\ + --ignore-existing\ + --size-only\ + -s \ + --exclude 'lost+found' \ + --exclude '.Trash-1000' \ + --exclude '$RECYCLEBIN' \ + --exclude 'System Volume Information' \ + --exclude '.thumbs' \ + $mirror_source \ + $mirror_user"@"$mirror_host":"$mirror_destination + fi + +} + function print_help () { echo "help" exit 0 } -#TODO: Add function to mirror backups +#TODO: Add function to recall backup by selection #TODO: Add function to automatically add key to keyring, if not found @@ -375,6 +437,9 @@ if [ ${#@} -gt 0 ]; then h) print_help ;; + m) + mirror_backup + ;; r) echo "recall" ;; @@ -433,6 +498,9 @@ if [ -n "$source_mode" ];then firefox) backup_single_directory $firefox_source $firefox_destination ;; + irssi) + backup_single_directory $irssi_source $irssi_destination + ;; thunderbird) backup_single_directory $thunderbird_source $thunderbird_destination ;; -- cgit v1.2.3-54-g00ecf