Saturday, 7 June 2025

rsync

 # To copy files from remote to local, maintaining file properties and sym-links (-a), zipping for faster transfer (-z), verbose (-v).  
rsync -avz host:file1 :file1 /dest/
rsync -avz /source host:/dest

# Copy files using checksum (-c) rather than time to detect if the file has changed. (Useful for validating backups).
rsync -avc /source/ /dest/

# Copy contents of /src/foo to destination:

# This command will create /dest/foo if it does not already exist
rsync -auv /src/foo /dest

# Explicitly copy /src/foo to /dest/foo
rsync -auv /src/foo/ /dest/foo

#rsync exclude for directory exclusion
rsync -avv /src/foo/ /dest/foo/ --exclude=/tools/
The leading slash / in the exclude is of great importance. It means match only at the base of the source tree. Assume the following:
tools/
src/
 - program.c
 - tools/

So there is the directory tools/ and src/tools/. exclude tools/ should exclude both of those directories named tools, whereas exclude /tools/ will only exclude the former (which is probably more often intended)

#Copy hard link as it is.
sudo rsync -az -H --delete --numeric-ids --progress /home/backups/vostroRsnapshot/ /mnt/tmp/backups/vostroRsnapshot/

# with ssh port number
rsync -av -e "ssh -p PORT_NUMBER" <SOURCE> <DESTINATION>:<PATH>
rsync -av -e 'ssh -p 3022' . user@127.0.0.1:~/make-this_folder

# with ssh port number and key
rsync -av -e "ssh -i private.pem -p PORT_NUMBER" <SOURCE> <DESTINATION>:<PATH>

TermRecord

TermRecord is a simple terminal session recorder with easy-to-share self-contained HTML output! TermRecord -o /tmp/session.html