Skip to content

Instantly share code, notes, and snippets.

@r0mdau
Created September 7, 2019 17:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save r0mdau/a7e5c60ca02687b743142aed1e0bf408 to your computer and use it in GitHub Desktop.
Save r0mdau/a7e5c60ca02687b743142aed1e0bf408 to your computer and use it in GitHub Desktop.
Rsync backup
#!/bin/sh
if [ $(mount | grep -c /media/romain/disk) = 1 ]
then
SOURCE="/home/romain"
ACTUEL="/media/romain/disk/raupi/actuel"
BACKUP="/media/romain/disk/raupi/$(date +'%Y-%m-%d')"
mkdir -p "$BACKUP"
/usr/bin/rsync -av --stats --delete --backup --backup-dir="$BACKUP" "$SOURCE" "$ACTUEL"
rmdir --ignore-fail-on-non-empty $BACKUP
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment