Information, Technology, Security, and other stuff.
Edit: gdrive has been updated to V2. This new post covers using it.
I had a Dokuwiki instance running at home, but I decided to migrate to Confluence instead to make it easier for non-technical people to use. The Dokuwiki product is super easy to back up, as it's entirely file-system driven. Confluence, however, is not so straightforward as it has the content stored in both a database and the filesystem.
In my case I've got my Confluence instance attached to PostgreSQL, so this article is suited for that. It shouldn't be hard to translate it for other DBMS platforms though. In addition, I've only got a single instance running so I don't know if this would be suitable for a clustered environment. Consult the product documentation for more info.
I'm using Google Drive (see my previous article on connecting a CentOS 7 box to gdrive) as the backup destination here, and I now have the backup being pushed into a specific folder (many thanks to Steven for pointing out how to upload to specific directories).
Also I'm encrypting the backup before it goes into the cloud. Always encrypt your data before it leaves your environment.
So this is my backup script, stored as
#!/bin/bash #stop confluence to prevent corruption systemctl stop confluence #back up confluence pg_dump confluencedbname -U confluenceadmindbuser -h localhost > /tmp/confluence.sql tar -cpzf /Confluence-Backup-$(date '+%Y-%m-%d').tar.gz /tmp/confluence.sql /var/atlassian/application-data/confluence/ rm -f /tmp/confluence.sql #start confluence again now, as the next steps may take some time systemctl start confluence #encrypt the backup openssl aes-256-cbc -salt -in /Confluence-Backup-$(date '+%Y-%m-%d').tar.gz -out /Confluence-Backup-$(date '+%Y-%m-%d').tar.gz.enc -pass pass:UsEaPaSsWoRdGeNeRaToRtOmAkEsOmEtHiNgRaNdOm #delete the cleartext backup rm -f /Confluence-Backup-$(date '+%Y-%m-%d').tar.gz #upload the encrypted backup to google drive drive upload --file "/Confluence-Backup-$(date '+%Y-%m-%d').tar.gz.enc" -p 0B35WT9E83exTfkQ3cEhXaGJ24g2jhHrhhjoVdgers24MbDE3YUNUTnRDR28 #delete the encrypted backup rm -f /Confluence-Backup-$(date '+%Y-%m-%d').tar.gz.enc exit 0
And finally to get the script running daily at 4AM:
chmod 500 /scripts/daily-backup.sh echo "0 4 * * * root /scripts/daily-backup.sh" >> /etc/crontab