Skip to content

Instantly share code, notes, and snippets.

@Andarius
Created July 22, 2020 12:36
Show Gist options
  • Save Andarius/32b519f05e4cce6dbd141c494169ece0 to your computer and use it in GitHub Desktop.
Save Andarius/32b519f05e4cce6dbd141c494169ece0 to your computer and use it in GitHub Desktop.
Backup data
#!/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