Making folder backups using Cron

Cron JobsAs I mentioned in yesterdays post on making backups of mySQL databases, earlier this year I migrated from a Microsoft Windows based web hosting package to a Linux based one. This meant I had to learn a few new ways of doing things, such as backing up databases or files, on a regular repeating basis.

This is accomplished on Linux web hosts using the Cron time-based scheduler. I needed to create two types of cron jobs; one to backup databases and one to backup files. Yesterdays post was on the databases and todays is on backing up files.

The syntax for backing up a files using Cron jobs will largely be the same on all web hosts.

The below example shows the syntax to backup a files, with the sections to change highlighted:

/*
Created by Ian Grieve of azurecurve | Ramblings of an IT Professional (http://www.azurecurve.co.uk) This code is licensed under the Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International (CC BY-NC-SA 4.0 Int). */
/bin/tar -czvf /home/{username}/backups/backup_{sitename}_$(date +\%Y\%m\%d\%H\%M\%S).tar.gz /home/{username}/{foldername}

What should we write about next?

If there is a topic which fits the typical ones of this site, which you would like to see me write about, please use the form, below, to submit your idea.

Your Name

Your Email

Suggested Topic

Suggestion Details

3 thoughts on “Making folder backups using Cron

Leave a Reply

Your email address will not be published. Required fields are marked *