How to do remote backup with tar and ssh ?

Extracted from Web submission
Tip provided by Guillaume
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 Leon to Tony                                                                    

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 tony "mv -f /home/backup/leon/$tgz /home/backup/leon/$old";
 #Tony is a i486... be patient !                                                               
 sleep 5m
 #THE ligne that makes everything                                                              
 tar -cz $file/* | ssh tony "cat - > /home/backup/leon/$tgz";
 sleep 5m
done


[ note of LTT maintainer : 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. ]

Follow-up :
| Previous | Next | Index of category | Main Index | Submit |


Appears in section(s) : net security
Tip recorded : 27-07-1999 19:28:03
HTML page last changed : 27-07-1999 20:07:25