Distribute backups to local machines
If you are a team as ours you are probably working remotely, with laptops, anywhere you can, anytime you can. This mean that all of our machines are “on the cloud”, they do run, scale and backup entirely automatically.
But what if you want to add one more line of defense – copying the backups locally to your machine from time to time. In this way even if in sequence of unlikely and strange events that corrupt your remote machines, you would have a local backup of your important information. But as in our case most of the time we forget to do a copy to a local machine. That’s why I would like to make it automatic.
What we are currently doing is copying a backup from remote to local every time your machine starts its Internet interface. And yes, this would would not scale for GB backups. But we are still not there.
This is the script:
# Copies production_backup on this machine
# This script should be copied at /etc/network/if-up.d/. In this way everytime the network starts a backup would be made
echo “Starting script:” >> /tmp/production_backup_copy.log
# Don’t bother when lo is configured.
if [ "$IFACE" = lo ]; then
#~ # Only run from ifup.
if [ "$MODE" != start ]; then
if [ -f $LOCAL_PATH ]; then
echo “File exists locally” >> /tmp/production_backup_copy.log
sudo su – $USER_WITH_ACCESS -c “cd $REPOSITORY; scp root@elvis:$REMOTE_PATH .”
echo “Pulling at: $(date +”%D %T”)” >> /tmp/production_backup_copy.log
This script is then added at
Now we have a distributed backup system, where simultaneous fail of all the machines and processes is impossible (except if someone starts a earth big Electromagnetic impulse)