Excluding Folders From a Cron Backup

Cron JobsA while ago, I posted an article on using cron to make backups of folders on Linux web hosting. One issue I’ve become aware of since then is that there are some folders I want to exclude from the backup process. I did some exploring and found the --exclude switch can be used to exclude a single folder; to exclude multiple folders, you can use the switch multiple times.

The example below, excludes the backup folder and anything which has a name starting with a .:

/*
Created by Ian Grieve of azurecurve|Ramblings of a Dynamics GP Consultant (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_{foldername}_$(date +\%Y\%m\%d\%H\%M\%S).tar.gz --exclude=backups --exclude=".*" /home/{username}/{foldername}

The highlighted section shows the two exclude switches used to exclude the folders and files we don’t want to backup.

Can ISC Software Solutions help?

ISC Software Solutions are UK and Ireland based experts on Microsoft Dynamics GP. If you'd like to speak to someone about support, consultancy, upgrades, implementation, development, GP Elementz add-ons or portals, or anything else Dynamics GP related, you can use the form below.
Your Name (required):
Your Email (required):
Subject:
Enquiry message:

What should we write about next?

Your Name (required) -
Your Email (required) -

Leave a Reply

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