Why Backups Matter 0:00Have you ever lost the contents of a database before? Well, I can tell you from my own experience, accidentally dropping a table or two, it sucks a lot. Fortunately, I was able to restore everything from a backup that we had taken previously. Forge provides automated database backups as part of its business plan, and when configured, Forge can automatically perform these backups on a schedule of our choice. The backup archives can be configured to upload to any S3 compatible storage provider, so there's no excuse for data loss when backups are made this easy. To get started, we need to head over to the backups panel on our server. This panel will be available for any app or database servers, you know, since we need Creating a Backup 0:35To get started, we need to head over to the backups panel on our server. This panel will be available for any app or database servers, you know, since we need a database on the server to actually take a backup of. OK, let's scroll down and start filling in this form. So the first thing that we can do is provide an optional name for our backup. This is particularly useful if we're going to configure multiple backups on this server, and it's just a good way of quickly identifying a backup, and maybe a backup failure email. For this, I'm going to call it ZondaDB. The next thing we can do is select the schedule that we're going to backup, and this is just a frequency that determines how often these backups are going to be taken. Setting the Schedule 1:11The next thing we can do is select the schedule that we're going to backup, and this is just a frequency that determines how often these backups are going to be taken. Forge already provides us with some common frequencies, hourly, daily and weekly. And as we select daily or weekly, then we'll be shown the day of the week and the time that we want to backup. For daily, we're just going to see the time. Of course, if we want to backup on our own schedule, then we can select the custom option and Forge will ask us to provide a cron expression. This is because Forge is actually just configuring our servers to run our backups using the server's own cron service. Choosing Storage Provider 1:40This is because Forge is actually just configuring our servers to run our backups using the server's own cron service. Of course, this does mean that our backups will run on our server's time zone. For this backup, I just want it hourly, please. Once we've decided on our backup frequency, we can choose where we want to store our backups. Forge's backup system is compatible with any Amazon S3 compatible storage provider, though occasionally a provider may not be 100% compatible and you might need to make some manual adjustments. However, if we're using Amazon S3, DigitalOcean Spaces or Scaleway, then Forge is already 100% compatible. And again, we can always select the custom option if we want to use another provider.100% compatible. And again, we can always select the custom option if we want to use another provider. But no matter which provider we select, we'll always need to let Forge know where we're storing the backups. But no matter which provider we select, we'll always need to provide Forge with some information telling it exactly where it's storing those backups. In this case, I'm going to use DigitalOcean Spaces. And I'm going to select Amsterdam 3. And my bucket is called Forge Backups Test. I already have my access and secret keys generated, so I'm going to provide those now. Retention and Notifications 2:46And my bucket is called Forge Backups Test. I already have my access and secret keys generated, so I'm going to provide those now. By default, Forge is going to store backups in the root of the bucket. But if we don't want to do that, then we can also provide a storage directory to store them in. I'm going to call it Zonda Database Backups. Next, we can select how many backups that we want to retain. On an hourly backup schedule, we might want to configure 24 hours so we can go back to any hour of the day. And then after those 24 have been created, then Forge will start to prune them off theany hour of the day. And then after those 24 have been created, then Forge will start to prune them off the end with the oldest backups being deleted first. We can also provide Forge with an email address that will be notified if any of our backups fail. And then finally, we can select which database or databases we want to backup. We can select all databases or one database or two, whatever it might be. For this, I'm just backing up the Zonda database. With all this information provided, we can create our backup. And when we click this create button, then Forge is actually going to validate all ofWith all this information provided, we can create our backup. And when we click this create button, then Forge is actually going to validate all of the credentials. And if they're incorrect, we can fix them up and just try again. So when we're creating a new backup configuration, Forge is creating a bash script on our server. And this is what's executed by the cron service. This script tells the server to dump the database and stream the contents to our S3 storage provider. And once it completes, whether it's successful or not, then the script is going to ping back to Forge with that status and send us an email notification if we've configured it. Running and Downloading Backups 4:16And once it completes, whether it's successful or not, then the script is going to ping back to Forge with that status and send us an email notification if we've configured it. At the time of recording, Forge doesn't actually support Slack failure notifications, but a way of working around that is to use Slack's email-to-channel hook and supply this as the email to receive notifications. That way we can start to receive notifications in our company's Slack channels. Now that Forge has finished creating the backup configuration, we'll manually run our first backup. Because this database only contains our small Zonda database, it'll only take a few seconds to complete.Because this database only contains our small Zonda database, it'll only take a few seconds to complete. And now we can see that the last backup was successful and taken four seconds ago. If we scroll down a bit further, we can see our recent backups with the name and ID of the backup configuration, the date and time that the backup was taken and how long that took. One of the cool things of Forge's backup feature is that we can also download the database archive directly from our browser. If we just click the name of the database, Forge is then going to download that file for us and we can see it's created there.If we just click the name of the database, Forge is then going to download that file for us and we can see it's created there. Then we can see the databases in this backup and also the status of it. If our backup has failed, then we can also choose to see the backup output. This will allow us to see what's gone wrong with the backup and we can contact Forge support or make any adjustments to our backup configuration. Okay, so let's verify that this backup has been created. I'll switch to DigitalOcean Spaces dashboard, give this a refresh. And we can see we have the directory that we told Forge to use. We'll click into that and we'll see the timestamp of when the backup was taken. Restoring from Backup 5:46And we can see we have the directory that we told Forge to use. We'll click into that and we'll see the timestamp of when the backup was taken. And if we go into that, we can see our database file. Let's switch over to TablePlus and we can see that we're on our Zonda database. This database contains a few tables, all of which are pretty much empty. So what we can do is select our tables and delete them. And then we can go back to Forge and click restore. Now, of course, because we're able to download those individual database archives, we could always choose to restore manually and with an application like TablePlus, choose which tables that we want to restore.always choose to restore manually and with an application like TablePlus, choose which tables that we want to restore. In this case, we've deleted all of the tables. So we need to restore that whole Zonda database. Forge is now going to download this archive to our server, extract it and then import it to our database. Let's switch back to TablePlus, give this a refresh, and we can see that Forge has now restored all of our tables and our data that was in those. And then finally, if our backup configuration changes, we can always go through and edit this. Editing Backup Settings 6:48And then finally, if our backup configuration changes, we can always go through and edit this. Here we'll see all of that information again, and we can choose to modify it and then save it.