You just spend several hours working on a new MODx powered website, but unlike normal websites there are no files for each page. The question now is how do we ensure all your hard work is protected from disaster? The answer is very simple, you backup your website. There are several methods to backup a MODx driven website, the question is which method works best for you.
There are two key aspects you need to backup:
There are several methods you can use to backup a MODx site each having pros and cons. Pick the method that best meets your needs and rest easy knowing your site is safe from a server disaster. Please keep in mind these methods are based on my experience so your results may vary based on host, server configuration, or other variables. All methods require you know how to login to your server via ssh or a control panel along with using an FTP or SFTP client.
A direct backup is done using the standard tools found on most servers and can actually be done several ways depending on the time you want to invest. The concept is very simple we are going to save a copy of all the files on your site along with a copy of your database. This can all be done using shell commands, but as my shell skills are lacking I will stick using cpanel as is found with most hosting companies.
The general process is as follows:
The file you saved above is your database which store all the content from your site. You can find your chunks, snippets, users, pages, etc. store in this file and as such I suggest backing it up on a more regular basis depending on how often your site changes.
Using your FTP/SFTP client:
You could also use a combination of the two methods the first to compress the site the second to download the zip using your FTP/SFTP client. Compressing the site to a single file will speed the download process as one large file is faster to download than lots of small files.
This method requires you go through several steps and as such will take longer to complete. It's only recommended if your site changes infrequently or you only manage a couple sites. The other methods are suggested if you have a few sites and/or wish to speed the process.
If your site changes on a regular basis or you manage a few websites, the above method isn't for you. The key to making backups a success is doing them regularly, so with this progression we eliminate a good deal of the work and automate it using cron jobs (scheduled tasks). I may be good with HTML and CSS, but you wouldn't want to rely on scripting skills.
I recommend using the backup scripts provided by B&T here: tips-scripts.com (Automated File Backup | Automated Database Backup) These are both provided free of charge and work well for any website, not just MODx powered websites.
You can read more about setting up these scripts on B&T's website so I will skip ahead some. I would recommend running the database backup script daily and the file backup script on a bi-weekly or monthly basis depending on how often your site changes. I only use the database script as you will learn later.
The end result after the scripts have run are two compressed zip files so for the second half of this backup method we just need to retrieve these files from the server. This can be done with cpanel, but personally I find it easier to just use a FTP/SFTP client so here are the steps:
This method has the best balance between time spent and ease of restoration. The problem with this method is if you use automated file backups and forget to delete old backups you will quick run out of server space and your backups could backup your backups thus making some large backup files. Database backups can also be bad, but with most databases being 1-2MB it will take longer to fill your server.
If you use cpanel you have a great built in backup utility that will gather all your files, databases, email address, and other settings in one zip file. This is known as a Full Backup which can be used to move between hosting companies or recover from a full server failure among other things. I use automated database backups in addition to control panel backup as most updates on my sites are done in the database.
Generating a cpanel backup is rather simple:
Depending on the size of your site it will take about 10-20 mins to generate a backup, this is also directly affected by your current server load so it's best to do this off peak hours. After you get the email you need to login and download the backup. You can go through the above steps and click the link when your backup finishes instead of generate, or you can download the file using your FTP/SFTP client as follows:
If you are looking for a more built in system for MODx, you may want to have a look at ModBak. It's a module you can install that automates the process of backing up your site. It wraps up the database and files for your install and provides them in an easy to download zip file. This can all be done in one place quickly. The last time I used this system it was tricky to setup, but once working it did a great job.
The best backup method isn't the one I use, but the one that works best for you. Yes, I can suggest different options, but if you don't follow through with these methods they are worthless. I've seen my fair (or unfair) share of business owners in tears... Why? They just lost everything on their main business computer due to a hard drive crashing, virus infestation, or user error. The killer is until they lost everything they never thought about backups even if they had a drive for backups.
I can't stress this point enough as I would rather avoid another crying adult... Backup, Backup, Backup!
The easiest method to backup a site is by using the cPanel backup system, it saves everything, but restoring files can be tricky as this method is likely designed for server transfers or full server recovery. The next best method would be the Direct Backups with Automation so you just download a few files on a regular basis. It's far easier to restore the Direct Backups, but it takes a good deal of time.
This information is hardly a definitive guide and I am hardly an expert on the subject. If you have any suggestions on how I can improve this information then please let me know!
7/16/2015 - The tips-scripts.com website is no longer available, the links have been updated to use the internet archive.
The MODx developers recently celebrated the launch of MODx Revolution. A total rewrite of the CMS many have known to grow and…
If you are considering the MODX books by Packt Publishing, give a little extra thought to why you want them.
The MODxpo videos get an upgrade!
Valeska Scholl's well written MODx Content Management System Content Editors guide in HTML for those not wanting to use the PDF…
© 2008 - 2018 AMDbuilder. The views expressed on this site are mine alone.