Thursday 30 April 2020

Nextcloud Address/Calendar Bbackups

I've been looking at an easy way to mirror my Nextcloud instance to a secondary server and came across Bernie_O's calcardbackup which neatly plugs a hole. While it is pretty easy to use rsync or similar to copy the files across the nextcloud database is a bit of a problem. You could use myqsl dump but that replicates the entire installation which is not quite what I want. However, when you get down to it, the bits that really matter are calendars and address books. The rest - user lists etc. are pretty much set up once and left alone.

What the script does is dumps out users calendars and address books in .ics and .vcf format - which can easily be imported when needed. What I do (as the web user) is:
  1.  Dump out the users data a files in the nextcloud admins account (not compressing them into a package, and only keeping 14 days backups):
    /usr/bin/calcardbackup/calcardbackup "/srv/www/htdocs/nextcloud" -x -r 14 -o "/srv/www/htdocs/nextcloud/data/admin/files/Backups"
  2. Tell nextcloud to rescan the admin's files to make them visible in the nextcloud client
    php /srv/www/htdocs/nextcloud/occ files:scan -p "admin/files/Backups"
  3. Once I conformed that these worked OK I added them to the web user's cron jobs to run daily at 2am
The dumps are then rsync'ed along with everything else.