File Synchronisation and Backup

Backup a remote directory over ssh using the wondertar

tar a remote directory and all content to the local machine over ssh without using disc space on the remote server. This is also called the „wondertar“ or „wonder tar“.

ssh user@remote-machine -p <port> "tar czpf - /remote/directory/source" | tar xzpf - -C /local/directory/target

And the other direction local to remote directory.

tar cpf - /local/directory/source | ssh user@remote-machine -p <port> "tar xpf - -C /remote/directory/target" 

https://meinit.nl/using-tar-and-ssh-to-efficiently-copy-files-preserving-permissions