myhome/.local/bin/backupSynologyMac

36 lines
1.2 KiB
Plaintext
Raw Normal View History

#!/bin/bash
2021-10-17 21:05:56 +02:00
MEGA_VOLUME="/Volumes/MEGA"
MEGA="$HOME/MEGA"
STARTED="$HOME/.config/backup-started-$(date +%d-%m)"
2022-07-10 01:26:53 +02:00
function main() {
if [[ ! -e "$STARTED" ]]; then
touch "$STARTED" && echo -e "[LOG] $(date) Created the file $STARTED"
echo -e "[LOG] $(date) Started $HOME/.ssh/ -> $MEGA/ssh"
rsync --bwlimit=2048 --update --progress -r "$HOME/.ssh/" "$MEGA/ssh/"
echo -e "[LOG] $(date) Finished $HOME/.ssh/ -> $MEGA/ssh"
echo -e "[LOG] $(date) Started $HOME/.gnupg/ -> $MEGA/gnupg"
rsync --bwlimit=2048 --update --progress -r "$HOME/.gnupg/" "$MEGA/gnupg/"
echo -e "[LOG] $(date) Finished $HOME/.gnupg/ -> $MEGA/gnupg"
if [[ -e "$MEGA_VOLUME" ]]; then
echo -e "[LOG] $(date) Started $MEGA -> $MEGA_VOLUME"
rsync --bwlimit=2048 --update --progress -r --exclude '.DS_Store' \
--exclude '.debris' \
--exclude 'Icon*' \
"$MEGA/" "$MEGA_VOLUME/"
else
echo -e "[ERROR] The folder $MEGA_VOLUME does NOT exist"
fi
echo -e "[LOG] $(date) Removed the files $STARTED and $STARTED *"
rm -rf "$STARTED"
rm -rf "$HOME/.config/backup-started-*"
fi
}
2022-07-10 01:26:53 +02:00
main >"$HOME/.config/backup.log"