Created
July 22, 2020 12:36
-
-
Save Andarius/32b519f05e4cce6dbd141c494169ece0 to your computer and use it in GitHub Desktop.
Backup data
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 | |
# set -xe | |
readonly BACKUP_FOLDERS=( /mnt/data/Projects ) | |
readonly TARGET=server:/folder | |
sync(){ | |
rsync -avz --exclude={.git,build,.idea,__pycache__,node_modules,target} --rsync-path=/usr/bin/rsync $1 $2 | |
} | |
get_count(){ | |
find $1 -type d \( -name .git -o -name build -o -name .idea -o -name __pycache__ -o -name node_modules -o -name target \) -prune -o -print | wc -l | |
} | |
backup(){ | |
for f in $BACKUP_FOLDERS; do | |
COUNT=`get_count $f` | |
sync $f $TARGET | tqdm --unit_scale --total $COUNT > /dev/null | |
done | |
} | |
backup |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment