Backup and Restore in Plone 5

Backing up the Server:

The easiest way to backup a Plone instance is via available packages – Add the below to your buildout.cfg and rerun buildout to apply:

parts =

recipe = collective.recipe.backup

sudo -u plone_buildout bin/buildout

Now you must run a backup – I do this nightly via a cron job with a script as follows:


# Completed Plone zinstance backups

# List directories to be backed up
dirs=”/opt/plone/zinstance/var/blobstoragebackups /opt/plone/zinstance/var/backups /opt/plone/zinstance/buildout.cfg”
bkp=/mnt/backup/plone-$(date +%Y-%m-%d).tar.gz

# Create log files
bkplog=/mnt/backup/plone-$(date +%Y-%m-%d).log
touch $bkplog

# Compress directories into zip
tar -czvf $bkp $dirs

This will create a new backup each day with accompanying log file which can then be transferred via SCP or another means to an archive server in case of catestrophic failure.

The restore process:

The first stage in restoring a plone server from a backup such as the above is to first install your plone server with all pre-requisits (Stopping before starting your plone instance for the first time). See this guide if you are unsure.

For the purposes of this guide – I have extracted the plone backup to /mnt/restore – Run the below commands to delete the default backup directories and plone buildout.cfg file.

rm -rf /opt/plone/zinstance/var/{backups,blobstoragebackups}
rm -rf /opt/plone/zinstance/buildout.cfg
cp -r /mnt/restore/opt/plone/zinstance/buildout.cfg /opt/plone/zinstance/
cp -r /mnt/restore/opt/plone/zinstance/var/{backups,blobstoragebackups} /opt/plone/zinstance/var/
rm -rf /opt/plone/zinstance/far/filestorage/*
chown -R plone_daemon:plone_group /opt/plone/zinstance/var/{blobstorage,filestorage}/
chown plone_buildout:plone_group /opt/plone/zinstance/buildout.cfg
cd /opt/plone/zinstance

Now you must run a buildout to install the backup/restore egg before starting your Plone server from the backup. I would suggest first running the instance in foreground mode so you can see any errors:

sudo -u plone_buildout bin/buildout
chown -R plone_daemon:plone_group /opt/plone/zinstance/var/{blobstorage,filestorage}/
sudo -u plone_daemon bin/plonectl fg

Now, assuming your backups were good and there were no errors – You can now start your instance in the background as normal.

sudo -u plone_daemon bin/plonectl start

Any comments or questions? Get in touch here or Email me at [email protected]