Inaugural public version, suitable for mass ridicule or pity.
This commit is contained in:
commit
a88d09bdb3
|
@ -0,0 +1,5 @@
|
|||
|
||||
Copyright D. Joe Anderson 2019
|
||||
|
||||
Available for use under GPL version 2 or any later GPL version.
|
||||
|
|
@ -0,0 +1,14 @@
|
|||
|
||||
# Snap and rotate
|
||||
|
||||
## Crude rotating rsync-based backup
|
||||
|
||||
This will probably destroy your data horribly so please use with caution.
|
||||
|
||||
I'm so behind-the-times I run it with cron.
|
||||
|
||||
[Mike Rubel was inspirational](http://mikerubel.org/computers/rsync_snapshots/)
|
||||
in his description of using rsync for backups.
|
||||
|
||||
He is not to blame for my poorly-considered implementation.
|
||||
|
|
@ -0,0 +1,55 @@
|
|||
#!/bin/bash
|
||||
|
||||
# Log the start
|
||||
|
||||
/usr/bin/logger Starting snap-and-rotate
|
||||
|
||||
# I start an ssh-agent, hand it a key, and put its env variables in agent-info
|
||||
|
||||
source $HOME/agent-info
|
||||
|
||||
|
||||
# remote host ssh is running on a non-standard port
|
||||
# security through security is a mug's game, kids, but
|
||||
# it keeps my logs cleaner
|
||||
|
||||
REMPORT=6666
|
||||
|
||||
# exclude what you want. I have a chroot running from which I want to exclude certain things
|
||||
|
||||
/usr/bin/rsync -e "ssh -p$REMPORT" -vaSHP \
|
||||
--exclude 'chroot/home/remuser/scratch' \
|
||||
--exclude 'chroot/proc' \
|
||||
--exclude 'chroot/sys' \
|
||||
--exclude 'chroot/dev' \
|
||||
--delete \
|
||||
root@myvps.example.com:/mnt/sda/ $HOME/scratch/snapshot/myvps/snapshot/
|
||||
|
||||
# Yes, as root. I know, I'm a monster unfit for human company.
|
||||
|
||||
# Also, remote host has drive I want bind mounted on /mnt/sda.
|
||||
# You need to figure out how you want to deal with this yourself.
|
||||
|
||||
# Wasteful, but whatever
|
||||
|
||||
rm -rf $HOME/scratch/snapshot/myvps/daily/$(date +%d)
|
||||
|
||||
# Also wasteful. Meh.
|
||||
|
||||
cp -al $HOME/scratch/snapshot/myvps/snapshot \
|
||||
$HOME/scratch/snapshot/myvps/daily/$(date +%d)
|
||||
|
||||
# Monthlies, yay.
|
||||
# Script should check for and create subdirs if necessary, probably.
|
||||
|
||||
if [ $(date +%d) -eq 17 ]; then
|
||||
cp -al $HOME/scratch/snapshot/myvps/daily/15 \
|
||||
$HOME/scratch/snapshot/myvps/monthly/from-the-15th/$(date +%m)
|
||||
fi
|
||||
|
||||
# rm, cp, and date above should all be given full paths probably
|
||||
|
||||
/usr/bin/logger Finished snap-and-rotate
|
||||
|
||||
# Log the end. The End.
|
||||
|
Loading…
Reference in New Issue