Monday, January 14, 2008

Backup using tar and ssh

Doing backup is important. You do not want to store your backup at the same machine where the data is stored. It is to avoid data loss when the machine broke down. To do this job, you can use tar paired with ssh to archive your important data and transfer it through network to another machine. Below are the steps:

1. Make sure the backup machine is installed with ssh server and the service is running
# yum install openssh-server
# service sshd start

2. Go to the folder where you want to backup. Use tar to archive and send it though network to backup machine
# tar -cvjf - /path/to/backup | ssh user@backupmachine "cat > /home/backup.tar.bz2"

3. Finish. Congatulations, your backup file is now safely kept in the backup machine

2 comments:

masuran said...

Probably a better way to do this is to use rsync. You can create incremental backups with rsync and copy them over using ssh.

Or have a look at GPB Backup or RSnapshot.

http://www.masuran.org/gpb/
www.rsnapshot.org/

blackorga said...

Yeah, that is also one of the way. Thanx man. By the way, I wrote about rsnapshot previously. Refer this: http://linuxwave.blogspot.com/2007/07/system-backup-using-rsnapshot.html