Skip to content

Instantly share code, notes, and snippets.

@rileyrg
Created August 20, 2014 22:54
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 rileyrg/92aa9e5a431d39ea07fe to your computer and use it in GitHub Desktop.
Save rileyrg/92aa9e5a431d39ea07fe to your computer and use it in GitHub Desktop.
#!/bin/bash
mountpoint="${1-/media/debianbackup}"
sudo mount "${mountpoint}"
mount | grep "${mountpoint}" >/dev/null
if [ "$?" -eq 0 ]
then
sudo rsync -aAXv /* "${1-"${mountpoint}"}" --exclude={"${HOME}"/.cache,/dev/*,/proc/*,/sys/*,/tmp/*,/run/*,/mnt/*,"${mountpoint}",/media/cdrom0,/lost+found} --delete
echo "Unmounting "${mountpoint}""
sudo umount "${mountpoint}"
else
echo "ERROR : "${mountpoint}" can't be mounted. Aborting."
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment