In this example, restore tar backup over ssh session from the remote machine to local dir: $ cat | ssh "cd /path/to/dest/ tar zxvf -" # tar cvzf - /wwwdata | ssh $(mt -f /dev/nst0 rewind cat > /dev/nst0)$ How to extract tar over ssh One can can use mt command to rewind tape and then dump it using cat command: # tar cvzf - /wwwdata | ssh "cat > /dev/nst0" # tar cvzf - /It is also possible to dump backup to remote tape device: You can also use dd command for clarity purpose: You can read more about tape drives naming convention used under Linux here. The default first SCSI tape drive under Linux is /dev/st0. $ ssh 'tar czf - /home/vivek' | tar xvzf -C /home/vivek Use tar command through network over SSH session for tape device Open the terminal on x230 laptop and run the ssh command along with tar command: The problem with scp and other command copying the directory structure is that Symbolic links, special devices, sockets, named pipes, and other stuff not copied. # ssh 'dd if=prod-disk-hostname-sdvf-dd-mm-yyyy.img' | dd of=/dev/sdvf Moving data to a new Linux system For instance, we can restore a local hard disk drive from the image stored on the remote AWS EC2 cloud backup server as follows: To restore a local drive from the image on the server, reverse the command. # dd if=/dev/sdvf | ssh 'dd of=prod-disk-hostname-sdvf-dd-mm-yyyy.img' Let us copy the entire hard disk drive named /dev/sdvf from local machine to the remote AWS EC2 cloud backup server: $ ssh 'tar zcf - /some/dir' | tar zxf - Linux system hard drive backup/mirror using tar and ssh # tar zcvf - /Use of tar command over ssh sessionsĬopying from the remote machine () to local system is as follows: To avoid this problem pass the -t option to the ssh command: Sudo: sorry, you must have a tty to run sudo Please note that you may get an error that read as follows with ssh command when using with sudo or any other command that needs a pseudo-terminal allocation: $ tar zcf - /data2/ | gpg -e | ssh 'cat - > .gpg' In this example archive /data2/ with gpg: # tar zcvf - /Sample outputs: tar: Removing leading `/' from member names The following command backups /(IP 192.168.1.201) host over ssh session: $ ssh 'cd /dir1/ & tar -cf - file | gzip -9' > The syntax is as follows to ssh into box and run the tar command:
0 Comments
Leave a Reply. |
Details
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |