Come creare un archivio tar in locale di una cartella su un server remoto tramite SSH su Linux

In questo articolo andremo a descrivere come creare un archivio tar in locale di una cartella situata su server remoto tramite SSH.

Consideriamo di avere due macchine preinstallate CentOS 7 ( qui per l’installazione) ed aggiorniamole

yum update

sulla prima macchina creiamo un file

[server1]# touch file1.txt

mentre sulla seconda attraverso il protocollo ssh creiamo il tar di file1.txt senza dover utilizzare ulteriore spazio sulla macchina 1

[server2]# ssh root@server1 "tar -czf - /root/file1.txt" >  file1.tar.gz

avremo

[server2]# ls -ltr

-rw-r–r–. 1 root root 141 20 mar 08.23 file1.tar.gz

[server2]# less file1.tar.gz

-rw-r–r– root/root 10 2020-03-20 10:35 file1.txt

Potrebbero interessarti anche...