Monday, 7 September 2009

How to tar backup on tape through ssh

# tar -cvzf /www | ssh root@station.domain.com "cat > /backup/www.tar.gz"


OR


# tar zcvf - /www | ssh root@192.168.1.101 "cat > /backup/www.tar.gz"


Output:



tar: Removing leading `/' from member names

/www/

/www/n/xx.in/

/www/c/zasx.asd/

....

..



You can also use dd command for clarity purpose:


# tar cvzf - /www | ssh root@192.168.1.101 "dd of=/backup/www.tar.gz"


It is also possible to dump backup to remote tape device:


# tar cvzf - /www | ssh ssh root@192.168.1.101 "cat > /dev/st0"


OR


you can use mt to rewind tape and then dump it using cat command:


# tar cvzf - /www | ssh ssh root@192.168.1.101 $(mt -f /dev/st0 rewind; cat > /dev/st0)$


You can restore tar backup over ssh session:


# ssh root@192.168.1.101 "cat /backup/www.tar.gz" | tar zxvf -

No comments:

Post a Comment