I just learned about the rsync command which is amazingly useful.
I have been using scp to copy folders from one machine at home to a machine in the lab back and forth and so far it's been good, and dead simple, but always involved extra work like making
moving directories around.
Now that I learned rsync, I can simply back up my work from the lab to my machine and vice versa using a simple command.
Here is the command I use:
rsync --delete -ravuzn -delete-excluded --exclude=*~ --rsh=ssh ~/work/ firstname.lastname@example.org:~/work/
and then, (notice I remove the n flag)
rsync --delete -ravuz -delete-excluded --exclude=*~ --rsh=ssh ~/work/ email@example.com:~/work/
so what does this command do:
--delete: if I have removed files from my local computer, they are also deleted on the server
r: recursively go through the folders and subfolders
v: verbose mode
z: compress files
--delete-excluded: deletes excluded files passed as parameter (next flag)
--exclude=*~ : tells to exclude files ending with tilda (~)
there is also -b, which is for backup. It will create a file with ~, whenever we delete a file on the machine to which we are syncing. That might be useful if you don't want to delete some important work.
Also, there is flag n, which runs the rsync command as a dry run. This way, you can see what will happen when you run the same command without the n flag. This is the one I will always use first so that I am sure I know what will happen!
Thanks to this website: