tar over ssh

make a remote archive of a local directory, well known, very useful command. If you need to backup something but have no (not enough) local space left.
tar command for creating archive z is for gzip v is for verbose c is for create and f is for file.

tar czvf - <directory> | ssh [username@]<hostname | ip adres> "cat > <archivename>.tar.gz"

so to archive foobar's home directory to remote host at 127.0.199.166 and put the archive in directory backups and name it foobarshome.tar.gz

tar czvf - /home/foobar | ssh root@127.0.199.166 "cat > foobarshome.tar.gz"

using a hostname

tar czvf - /home/foobar | ssh root@remotehost "cat > foobarshome.tar.gz"