Category: Server Administration

I recently inherited a project from a beginning developer. After inheriting the project I realized that, while the developer was using Git to source control the project, the developer had completely forgot to add a .gitignore.

This meant that I now needed to add a .gitignore file as well as remove files from git that were tracked that shouldn’t have been tracked.

This isn’t usually a big deal when ignoring a single file or two — The command to remove a single file is:

git rm --cached <file>

But, since we use Grunt and Sass for our web development projects, there were a ton of files within node_modules and .sass_cache as well as .DS_Store files throughout.

To get around writing multiple commands to ignore all of these files and un-track them, I did this:

I work on some servers at my University. Recently our RAID server went out, which means that we could potentially lose all student and professor data across several of our servers. I was tasked with getting some sort of backup going from our main servers to a local backup server.

After thinking about how to approach the problem, Dr. Awesome (Terry Griffin) and I decided that Rsync would be a good way to go, at least until we could get another RAID server.

The Command

The Command Explained

Note that I am using sudo on both the local server and remote server. You will need to be in the sudoers file on both machines to use this command. Sudo let’s you run a command as the super user, which essentially means you are awesome and can do anything.

Next, we have rsync with some options. The rysync command is what is used when you want to do a remote sync. Then the options are explained as follows:

a = Archive – This creates a tar of the directory that you want to backup, which allows you to keep permissions, times, etc. in sync.

r = Recursive – This option will allow the rsync to copy throughout the target directory.

v = Verbose – This option will print give you updates on the screen as the rsync command runs.

Other Notes

You can be more specific about what is copied by deciding to put a “/” at the end of a directory or not.

For example, if you a “/” at the end of the source directory, then rsync will copy the content of that folder. If you don’t put a “/” at the end of the source directory, rsync will copy the source directory and its contents.

If you put a “/” at the end of the destination directory, rsync will paste the contents into that directory. When you don’t use “/”, rsync will create a directory and paste the contents within that directory.

Search for:

Sort by

Subscribe to Blog via Email

Enter your email address to subscribe to this blog and receive notifications of new posts by email.