![]() See GNU/tar home page and documentation here for more info $ tar cvf - /wwwdata | ssh "cat > /backup/wwwdata.tar" In some cases, you can avoid the compression off at both ends when doing tar over ssh to make file transfer faster. You learned how to use the tar command over ssh sessions to transfer archives, files, and images securely. $ tar -zcvf /data/ /home/vivek/ Conclusion You can use sshfs to mount a remote directory and run tar command: $ man ssh A note about SSHFS – a FUSE filesystem Make sure you read the tar command/ssh command/bash command man page for more info using the help command or man command: ![]() $ tar cvjf - * | ssh "(cd /dest/ tar xjf - )" $ tar cvzf - /var/$ ssh "cat /backups/| tar xvzf. $ tar cvzf - mydir/ | ssh "cat > /backups/myfile.tgz" $ tar cvjf - * | ssh "(cd /dest/ tar xjf -)" | pv | ssh "cat > /backups/box42/backup-dd-mm-yyyy.tgz" The pv command allows you to see the progress of data through a pipeline. Hence, use the apk command on Alpine Linux, dnf command/ yum command on RHEL & co, apt command/ apt-get command on Debian, Ubuntu & co, zypper command on SUSE/OpenSUSE, pacman command on Arch Linux to install the pv. How to tar over SSH with progress barīy default, pv command may not be installed on your system. If you wish to use above command in cron jobs or scripts then consider SSH keys to get rid of the passwords. 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. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |