Remote backup with tar and ssh

. Saturday, November 3, 2007
  • Agregar a Technorati
  • Agregar a Del.icio.us
  • Agregar a DiggIt!
  • Agregar a Yahoo!
  • Agregar a Google
  • Agregar a Meneame
  • Agregar a Furl
  • Agregar a Reddit
  • Agregar a Magnolia
  • Agregar a Blinklist
  • Agregar a Blogmarks

A short script can make it for you via ssh.
Advantages : esay to understand, secured, pretty fast,
no problem with 300 MBytes .tar files
between a 6x86 (64 Mo RAM) and a 486 (8 Mo RAM)


#!/bin/bash
# Backup from SYS1 to SYS2

cd /

list="home/www home/www2 etc var"

for file in $list
do
#Keep the previous backup
tgz=`echo $file | sed -e 's/\//_/g'`;
old="${tgz}.old";
#Store the old backup
ssh SYS2 "mv -f /home/backup/SYS1/$tgz /home/backup/SYS1/$old";
#SYS2 is a i486... be patient !
sleep 5m
#THE ligne that makes everything
tar -cz $file/* | ssh SYS2 "cat - > /home/backup/SYS1/$tgz";
sleep 5m
done


[ Note : both computers have to trust themselves so that
ssh won't ask for a password. See man ssh and man sshd for how to do that. ]

0 comments: