GridPane V1 Local Backups

5 min read

IMPORTANT

Local backups are an excellent tool for quick recovery on a site where a client or core/theme/plugin updates may have made broken things, or you've accidentally deleted the wrong website, etc. However, they should not be your only backup source for disaster recovery. Please see this article for our recommendations: Recommended Backup Strategy

Local Backups

Every GridPane server features a Local backups function. You can easily enable it by for every new site added via the GridPane dashboard.

Backups are run every hour on the hour 24/7. The local backups system stores an hourly backup for the past 12 hours, a daily backup for the past 7 days, a weekly backup for the past 4 weeks and a monthly backup for the past 3 months.

But because the backups are deduplicated, this time machine style backup is incredibly efficient with space.

You can toggle them on/off in the Site Customization pop up.

Limitations

The V1 backup system doesn’t include remote backups to third-party storage. These are stored directly on your server, so if your server was to ever go down, these backups would not be accessible until the server came back online.

Please ensure you also have third party backups for disaster recovery.

Excluded File Types

There are a few file types that are not backed up with the V1 Borg system.  One, in particular, you should be aware of is .zip files. Please ensure that you have a recovery plan in place for any of these file types if you host them within your websites. Alternatively, consider offloading them to an external system. 

.img, .iso, .wpress, .tar, .zip, and .gz file types are excluded:

--exclude '*.img' \
--exclude '*.iso' \
--exclude '*.wpress' \
--exclude '*.tar' \
--exclude '*.zip' \
--exclude '*.gz'

The above file formats, particularly .wpress, .zip, and .gz are the common extensions used by backup plugins such as All in One WP Migration. This precautionary measure ensures that your servers are not filled up with backups of other backups, and also ensures that your local backups continue to have enough space to run without either filling up the server or failing due to insufficient disk space.

Downloading local backups

Backup of the current site can be downloaded from the site customizer using the
SFTP download export option.
 
To select other backup options, you need to access the server via SSH as root then use borg commands to extract the archive.
 
Here are the steps to take. First, you will need to grab the borg password by running this command:
cat /root/gridenv/backups.token

Then you will need to list the backups available on the server.

borg list /opt/gridpane/backups/snapshots

Or you can list backups for a specific site using this command:

/usr/bin/borg list /opt/gridpane/backups/snapshots --prefix $site

then here is the command to extract:

borg export-tar /opt/gridpane/backups/snapshots::{name.of.snapshot} /path/to/output/name.tar.gz

Ex.:

borg export-tar /opt/gridpane/backups/snapshots::example.com-2021-06-20-23 /var/www/example.com/example.com-SFTP-export.tar.gz

Replace example.com with your site domain.

Modifying the local backup schedule

Local backups for all of your websites are managed as a cronjob. If you’d like to change the frequency of your backup schedule, the information below will get you going. This is particularly useful for those of you who run large websites that take a significant amount of time to backup – WaaS sites are a popular one that struggle with hourly backups

There is a cronjob for a process called gpbup in your crontab. You can see your crontab by running this command:

crontab -l

The line you are looking for looks like this:

0 * * * * /usr/local/bin/gpbup

The zero and the stars correspond to times. What the above is saying is to run the command gpbup(GridPane Backup) located in /usr/local/bin at minute zero of every hour, of every day, of every month, of every week. This is what is setup on your servers by default.

To change the schedule, you can adjust those values. Luckily for us, some awesome soul created https://crontab.guru that will help you set your own custom schedule, and below are some examples to get you started.

Example 1

Let’s say you want to change your backup schedule to twice a day. It’s best to keep it on the hour – the script likes that. Here is what we would use to change it to at the zero minutes of hours 0 and 12 (that’s 0 and 12 UTC by default, adjust for your timezone). That line would look like this:

0 0,12 * * * /usr/local/bin/gpbup

Example 2

If you wanted to change the frequency to once every 4 hours you could do:

0 0,4,8,12,16,20 * * * /usr/local/bin/gpbup

This schedule would run backups at 12am, 4am, 8am, 12pm, 4pm and 8pm. The image below highlights the hourly part of the schedule.

Example 3

If you wanted to change the frequency to once every 8 hours you could do:

0 0,8,16 * * * /usr/local/bin/gpbup

This schedule would run backups at 12am, 8am, and 4pm.

Editing the crontab

The command crontab -l only views the crontab. To edit the crontab you can run:

crontab -e

If you are presented with a choice, select nano as your editing tool. Then simply change the values on that line to set your schedule. Control+O will save the file (then press enter) and Control+X will close the file.

You can view the crontab again with crontab -l to confirm the changes, and you’re now all set.

Cronjobs and Timezone

By default your servers will be on UTC time. You can confirm this by running:

date

If you’d like to set your cronjobs to run specific to your timezone, you can change your timezone (GP CLI coming soon).

First run the following to list available timezones:

timedatectl list-timezones

Use your down-arrow key to navigate down until you find your timezone, and hit Control+C to exit once you’ve got it.

You can now reset your timezone with this command:

sudo timedatectl set-timezone

Examples:

sudo timedatectl set-timezone Europe/Paris
sudo timedatectl set-timezone Asia/Singapore
sudo timedatectl set-timezone America/New_York

Remote Backups

Remote backups are available as a part of our V2 backups system. You can learn more about this here:

Remote Website Backups 2.0C

Further Reading

For further information about how backup systems work, the available options for configuring them, and for setting up remote backups (available on V2), please see the articles listed below.

Strategy

Recommended Backup Strategy

V2 Backups

V1 Backups