VPSMATE

  • HOME
  • NEWS
  • VPS
  • DEDICATED
  • ARCHIVES
  • GoDaddy
  • SCRIPT
  • TOOLS
    • Traceroute
    • Benchmark
    • Useful Sites
  • Themes
  • GFW
VPSMATE
VPS COUPON & PROMOS | VPS & DEDICATED SERVERS OFFERS | VPS REVIEWS
  1. Main page
  2. Tutorials
  3. Main content

Howto: Use tar Command Through Network Over SSH Session

10/04/2014 133hotness 0likes 0comments

How do I use tar command over secure ssh session?

The GNU version of the tar archiving utility (and other old version of tar) can be use through network over ssh session. Do not use telnet command, it is insecure. You can use Unix/Linux pipes to create actives. Following command backups /backup directory to Remote_IP (IP Remote_IP) host over ssh session.

tar zcvf - /backup | ssh root@Remote_IP "cat > /backup/backup.tar.gz"
tar zcvf - /backup | ssh root@Remote_IP "cat > /backup/backup.tar.gz"

Output:

tar: Removing leading `/' from member names
/backup/
/backup/n/nixcraft.in/
/backup/c/cyberciti.biz/
....
..
...
Password:

You can also use dd command for clarity purpose:

tar cvzf - /backup | ssh root@Remote_IP "dd of=/backup/backup.tar.gz"

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

tar cvzf - /backup | ssh root@Remote_IP "cat > /dev/nst0"

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

tar cvzf - /backup | ssh root@Remote_IP $(mt -f /dev/nst0 rewind; cat > /dev/nst0)$

You can restore tar backup over ssh session:

cd /
ssh root@Remote_IP "cat /backup/backup.tar.gz" | tar zxvf -

If you wish to use above command in cron job or scripts then consider SSH keys to get rid of the passwords.

Related

Tag: Nothing
Last updated:23/04/2014

kyaky

This person is a lazy dog and has left nothing

Like
< Last article
Next article >

Comments

razz evil exclaim smile redface biggrin eek confused idea lol mad twisted rolleyes wink cool arrow neutral cry mrgreen drooling persevering
Cancel

COPYRIGHT © 2021 vpsmate.net. ALL RIGHTS RESERVED.

Theme Kratos Made By Seaton Jiang