Skip to content

Instantly share code, notes, and snippets.

@guysoft
Created October 20, 2019 13:06
Show Gist options
  • Save guysoft/bb5f9fb7aaea2346565c3eafa6239210 to your computer and use it in GitHub Desktop.
Save guysoft/bb5f9fb7aaea2346565c3eafa6239210 to your computer and use it in GitHub Desktop.
Nightly snapshot script, needs an email script at /home/guy/stuff/scripts/email
# Include
+ /dev/console
+ /dev/initctl
+ /dev/null
+ /dev/zero
# Exclude
- /dev/*
- /run/*
- /proc/*
- /sys/*
- /tmp/*
- lost+found/
- /media/*
- /mnt/*
- /srv/*
- /media/*
- var/lib/docker/aufs
#/bin/bash
SNAPSHOT_DEVICE=/dev/sdd1
# rsync backup script
mount $SNAPSHOT_DEVICE /mnt/snapshot
if [ -d /mnt/snapshot/laptop_nightly/ ]
then
sudo sh -c "
rsync -av --delete-excluded --exclude-from=/home/guy/stuff/scripts/snapshot/rootsystem_backup.lst / /mnt/snapshot/laptop_nightly/rootsystem --progress > /mnt/snapshot/laptop_nightly/rootsystem_log;
date > /mnt/snapshot/laptop_nightly/rootsystem_BACKUP
"
umount $SNAPSHOT_DEVICE
if [ -d /mnt/snapshot/laptop_nightly/ ]
then
python /home/guy/stuff/scripts/email "Laptop root nightly backup FAILED TO UNMOUNT /dev/sdd1 $(date)"
fi
python /home/guy/stuff/scripts/email "Laptop root nightly backup finished. All systems green. $(date)"
else
python /home/guy/stuff/scripts/email "Laptop root nightly backup FAILED at mount $(date)"
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment