Tar over ssh
Today I needed to backup a directory from one of my database servers so one our DBA’s could do an upgrade to oracle. I was running short on time and disk space on the current server. In the past I have just used scp to copy files from one server to the other but I aways forget about links and permissions.
I had saved an article about using tar over ssh in the past *( here is the artical ) so I thought it might be a good time to try.
I started looking for a UNIX server that had plenty of storage. Check!
Now for the gritty stuff!
tar zcvf /opt/oracle/ | ssh root@some.server.lan "cat
> /path/to/alot/of/disk/backup-file.tgz"
tar: Removing leading `/' from member names
./opt/oracle/
.
. .
. . .
root@some.server.lan's password:
Now go to the destination server and look and see if your backup-file.tgz is in the location you specified.
One of the best things about this is that it uses SSH so it is encrypted. If there was someone sniffing the traffic between the two servers they would not be able to see any usable data.
This shows you how to do it with being prompted for a password. If you would like to automate this you create a ssh key from server1 and put the public key on server2. Then you could write a small shell script that could be called from cron to run a you desired time.

Leave a Reply