Drupal 7 Backup and Migrate module
Backing up your website data is extremely important, however often times this backup process is forgotten until the day comes that it is needed. The Drupal 7 Backup and Migrate module makes this process extremely easy to implement and I highly recommend using this module if you are on some type of shared hosting or a server setup that makes it difficult to implement proper backups.
The Drupal Backup and Migrate module allows you to create manual backups or even schedule backups of your Drupal database. The module also implements a simple restore system so you can easily roll back your Drupal website to a previous point in time. If you were worried about setting up backups in Drupal because you thought it would be a long complicated process, your worries are over. Go ahead and give the Drupal Backup and Migrate module a try on your Drupal site.
In this module you will learn:
- How the Drupal Backup and Migrate module can be used to manually backup a Drupal database
- How the Drupal Backup and Migrate module can be used to schedule automatic backups of a Drupal database
- How the Backup and Migrate module can be used to easily restore a previous Drupal backup
- How to set up multiple backup profiles using the Backup and Migrate Drupal module
Hello everyone and welcome to another Daily Dose of Drupal, today we’re on Episode Number 76. As always I’m Shane, you can follow me on Twitter @smthomas3, also go to codekarate.com and sign up for the newsletter and if you’re on Google + you can find me there as well.
Today we’re going to be talking about primarily used for people who would administer Drupal websites and the module that we’re going to be looking at today is the Back-up and Migrate Module.
Now I’ve used this on the past, I don’t use this on every site because I do have a lot of back-ups from the server of level but if you are one of those people who are using shared hosting or something like that and you can’t really control the server, you can’t setup your own backup system the way you want to, the Back-up and Migrate module is just a fantastic module for being able to do that.
Let’s go ahead and get started and we’ll walk through some of the basics, I’m not going to go through all of it because it allows you to do quite a bit. It’s all based around being able to just back-up the database on your Drupal website and it allows you to do things like schedule back-ups, there’s even helper modules that you can look at for encrypting your back-up files, you can store the back-ups on the server or you can request it and have it downloaded so you can actually have a back-up file downloaded to your local computer.
So a whole bunch of different options here; we’re going to go through a few of them today and you can explore the rest yourself. Today we are on a test site here, just pretty basic, not a lot of content. I’m going to go ahead and hop over to the module’s page and show you that I already have the Back-up and Migrate Module installed.
Go ahead and you can check out the permissions here. There are quite a few permissions for the Back-up and Migrate module; there are permissions to access the Back-up and Migrate Admin section, perform a back-up, access back-up files, delete, restore and administer the entire Back-up and Migrate module. So you’re going to want to take a look at that and see who you want to allow to be able to access that.
Generally you’re just going to want administrators to be able to do that kind of stuff but it’s pretty flexible. We’ll go ahead and click on the Configure link here and now you have bunch of options here and a bunch of different menus.
The first thing you can do is do a quick back-up. Basically it’s going to back up the default Drupal Database and you can have it downloaded to go to the backup’s directory in the default settings. So I’m going to go and click Download and I’m going to let that run for a second and as you can see it has already pop down here, it gives me a file which I can open up.
Let me go ahead and pull this over here so you can see it and as you can see it gives me a g-zip of the actual database file. So I can save that and let’s say I want to come back and re-upload that or restore it. I just click Restore, choose the Back-up file and I’m ready to go.
So we’re going to go ahead and give that a quick test just to show you how that works. I’m going to come in here and I am going to add a new piece of content so I’m going to add just another test article here, I’m not going to spend a lot of time on it because it’s going to be going away here in a second, so I went ahead and save that.
Now if I come back into the modules page, find Back-up and Migrate and click Configure and I click Restore, I’m going to go ahead and choose the back-up options here, let me go ahead and find it, there it is and I hit restore now and it should go ahead and restore the file, you can see it gives you a little bit of information here, it also gives you a warning restore and we’ll delete some or all of your data and cannot be undone so it says always test it on a production server.
You can also force your site to go offline during that process which is potentially useful especially if you’re doing it on a live site. But now if we come back to the homepage you’ll notice that there’s still only two articles.
That third article that we just created is now completely gone just because we restore that back-up. So that’s how simple and easy it is to just roll back to another point in time using the back-up and migrate module, you can also do a lot more of it so let’s go ahead and take a look at some of this other tabs.
The Destinations options allow you to specify different destinations. There are two already setup for directories; one is the Manual Back-up directory so if you manually back it up it will be drop in this location on the server. So it says private back-up_migrate/manual. In case you’re wondering what the private actually means, I’ll show you that here in a second but the scheduled back-ups directory is very similar, private back-up_ migrate/schedule, it’s also the destination of the actual database itself. That is being backed up. So here in mine it looks like that, yours will probably look different especially if you’re running it on your own local host.
You can add another destination, you can add a server directory on my sequel database, you can even specify FTP directory. So if you want the back-up to be dropped in to a specific FTP location, you go ahead and fill out that information and you can specify that as a back-up directory, you can also use Amazon S3 although it does require if you read the note here it does require the installation of another library I’ve never used it but it’s very cool concept, you can have an Amazon S3 bucket and have all your back-ups to be stored in that one location and you can also have it sent through e-mail.
Probably not good for extremely large databases but if you have a simple site and you just want it e-mailed to you maybe every week or every day you can go ahead and specify e-mail location just by giving an e-mail address and just a name for your own preference and for your own use to have it show up here in this table.
Okay so now that we know what the destination are I’m going to go ahead and show you what this private means, if you come over here to the configuration page and click on file system it’s going to specify the public file and private file system paths so you can see that in my case the private file systems in the sites test.codekarate.com private files directory.
So I’m going to go back and I’m going to create a back-up and I’ve already done one so I’ll just do another one here and I’ll back it up to the manual back-ups directory and this is going to take a little bit of time but while I’m at it I will go ahead and pull up the website here. So you see it was in private files back-up migrate and then manual for the back-ups directory.
You can see that currently there’s one in here that I did earlier and as soon as this one is done backing up there will be more files that will be dropped into this location, it takes a few seconds here so you’ll see now that this has been created, I should be able to refresh here and you can see now there are more files in here that were manually backed up to this manual back-up directory, you can see I now have a message here saying the default database is backed up successfully, it gives you the name of the file and it tells you the destination, it also allows you to download that, restore it or delete it.
So now if we come into Destinations you go into the manual back-up directory, we can go ahead and list the files and it lists those two files and allows you to download those files from the server or restore them or delete those back-ups. So it’s already extremely useful but there’s even more. You can set up specific profiles, so when you’re backing up and you’re doing an advance backup you can specify the file name, the time stamp format, what type of compression you want to use, you can specify if you want specific tables or data to be dropped from tables so in this case by default it drops all of the cash tables, it also drops the washdog table which is all you logging so it doesn’t store the data of that in the backup, you can also have it send an e-mail if there’s a backup successful or a backup error, it also take the site offline.
So all these different options that you can set during an advance backup. The Profile section allows you to take it a step further and save that information into a profile which you can then use either during your scheduled backups or during your manual backups. So if I wanted to say … let’s say I wanted to use the default but I wanted the watchdog directory to be included for some reason on the watchdog data and the watchdog table.
So I’m going to uncheck this, I held control there to make sure these other ones are still selected and let’s also say I want to be notified if there’s a back-up error so this have it send an e-mail. So I go ahead and save the profile, now there’s a logging profile in the default settings. So now if I go to a backup you can see I can use this logging profile instead of the default settings.
The last thing that we’re going to go aver quickly is scheduling. This Schedules tab allows you to add a schedule. So if I want to create a schedule called Daily Backups I can select either my default settings or my other profile or leave it leave it a default, you can say backup every one day, you can specify how many backup files to keep you can also specify what destinations.
In this case that creates a schedule backup directory so I’m just going to go there, let’s say you only want to keep 30 backup files so this will in theory keep 30 days worth of data and it will then start deleting those each time. So we can go ahead and save the schedule and now if we run cron that should go ahead and create that backup.
So I’m going to hop over to the command line and run cron here and hopefully if everything is working correctly it should just create this backup, I’m assuming it’s going to create on the first cron run of the day and then the next time after midnight the next day … the next time cron run it should create a backup again.
So this will probably take a little bit of time to run so as I mentioned before; go ahead and follow me on Twitter if you’re not already, check out Google + and hey if you’re bored go ahead and mention me on Twitter and ask me a question or something like that. I usually try to get to them as quickly as I can, sometimes it takes a couple of days, sometimes a week but I generally do get to it eventually and while we’re waiting we’ll go ahead and open this up, you can see that a scheduled directory was created, this wasn’t here before and you can see that there is an info file created, the backup file is still on process or being created so it’s still spinning through that cron run and as soon that this is done it should be good to go.
Okay it looks like it’s finish now so if I refresh you can see the backup file is now been dropped into this schedule directory and as long as you have cron setup on your website this backup is going to be running, it’s going to be dropping those into that folder I can of course specify different destination, have it e-mailed to me, have it dropped on Amazon S3 or through FTP.
The other thing that you might want to consider is using the one of the contributed modules listed off this page to actually encrypt the backup file so someone can’t take your backup file and take all the information off of it without being able to decrypt it. So those are all things you can take a look at and as I said; this is a very useful module especially if you dint have something setup for backups already, it makes it really easy to restore to a past time and I highly recommend you use it on your Drupal sites if you need it. Thanks for watching the Daily Dose of Drupal and we’ll be back again next time.