A neat little snippet when migrating datasets between servers or creating archives to remote servers when disk space is limited. Here are some examples I've used extensively when migrating some RHEL7 Servers to RHEL8:
Creating archive locally and push to remote server:
[root@kvm ~]# tar -cvpJf - /srv/kvm/vm-images | ssh root@nas.archyslife.lan 'cat > /var/backup/vm-images.tar.xz'
Create archive remotely and pull to local server:
[root@nas ~]# ssh archy@kvm.archyslife.lan 'tar -cvpJf - /srv/kvm/vm-images' > /var/backup/vm-images.tar.xz
Pull archive from remote server and extract locally:
[archy@kvm ~]$ ssh archy@nas.archyslife.lan 'cat /var/backup/vm-images.tar.xz' | tar -xvJf - -C /
Push archive from local server to
[archy@nas ~]$ cat /var/backup/vm-images.tar.xz | ssh archy@kvm.archyslife.lan 'tar -xvpJf - -C /'
Feel free to comment and / or suggest a topic.
tar -cvpJf -
ReplyDeletewhat is the meaning of "-" at the end above?
The '-' will return the output of the tar command to the terminal where you can redirect it using '<' or '>'.
Deletecan you please post the same work for Rsync command?
ReplyDeleteAn example on how to use rsync over ssh (if it's just about that) can be found here:
Deletehttps://archyslife.blogspot.com/2018/12/creating-backups-in-linux-with-tar-and.html
Thank you so much.
ReplyDeleteI'm expecting this kind of technical post. Good work!