Backup for contacts and calendars


#1

Hello everybody,

I’m very new to owncloud, running on my raspi zeroW (stretch, php7, apache2). I have successfully installed and setup owncloud, migratet calendars and contacts. Now I want to backup calendars and contacts.
Is the mysqldump enough for that?
I tried to use
wget https://SERVER/remote.php/carddav/addressbooks/USER/ADDRESSBOOK?export
but get an certificate error even with --no-check-certificate.
So would I be able to restore contacts and calendars with the db backup, or using rsync to copy the whole install path /var/www/owncloud to a save place?
Thank you for your help

PS:
I now have a script which uses rsync to copy data and config directories as well as mysqldump of the database(s). Additionally I copy the whole owncloud directory and zip it. I hope this will be enough. Any thoughts or advises are much appreciated.


#2

I wrote a bash-script calcardbackup which backups calendars and adressbooks of all users. Please pay attention to the new option -f in the latest release: when using this option there is no need anymore to give the passwords of the users.


#3

Hey, I already tried your script, but there was also an error. Not shure what it was, I will look into that and report back. Maybe you can answer my question anyways?

PS: Just tried it and it worked like a charm! How can I set the output path?
PPS: Already found the examples and made a conf - Thank you very much!


#4

I’m getting this error, when running your script from my script. My script sets owncloud to maintenace mode, rsyncs data and config, mysqldump, then run your script and disable maintenance mode.

  • Compressing backup as *.tar.gz file. Be patient - this may take a while.
    tar: calcardbackup-2018-09-22: Datei hat sich beim Lesen geändert.
    – calcardbackup: ERROR –
    – ERROR: Compressing the files produced an error. See lines right above.
    – calcardbackup: Exiting.

#5

Is rsync syncing the output directory from calcardbackup while it is running?


#6

No, rsync only syncs data and config, then you script is invoked. I moved my script to the same folder as yours, then the script succeeded. As the error occurs when zipping the file it is not a big issue to me. As long as the ics and vcf files are backed up I’m fine with it.


#7

Strange.

I‘d quite like to understand what is going on there and fix it, if it is a bug in my script. Do you mind sharing your backup script and the calcardbackup configuration with me (remove sensitive values!)?


#8

I think it is not necesserily related to your script :laughing: but maybe we can figure it out what is going on.
Here is my script:

#!/bin/bash

#enable owncloud in maintenance mode
cd /path/to/owncloud
sudo -u www-data php occ maintenance:mode --on
cd

#backup data directory
sudo rsync -Aax /path/to/owncloud/data/ /path/to/external/storage

#backup config directory
sudo rsync -Aax /path/to/owncloud/config/ /path/to/external/storage

#backup database
mysqldump --single-transaction -h [HOST] -u [USER] -p[PASSWD] -A > /path/to/external/storage

 #invoke BearnieO's calcardbackup script
cd /usr/local/bin/calcardbackup
sudo -u www-data ./calcardbackup "/path/to/owncloud" -c /path/to/calcardbackup/conf

#disable owncloud maintenance mode
cd /path/to/owncloud
sudo -u www-data php occ maintenance:mode --off
cd

Here are the values from the config:

nextcloud_path="/path/to/owncloud"

nextcloud_url="https://ip.to.own.cloud" #should I use localhost here?

trustful_certificate="no"

#users_file="users.txt"

backupfolder="/path/to/external/storage/"

date_extension="-%Y-%m-%d"

delete_backups_older_than="0"

compress="yes"

compression_method="tar.gz"

encrypt_backup="no"
gpg_passphrase="1234"

backup_addressbooks="yes"
backup_calendars="yes"

fetch_from_database="yes"

include_shares="yes"

snap="no"

#9

Thanks. I can’t reproduce the issue on my machine when using your script and configuration.

Here is what calcardbackup does:

  • it saves the ics and vcf files in a folder named calcardbackup-date inside the configured output directory (backupfolder)
  • it creates a compressed archive of the folder calcardbackup-date as tar.gz with tar
  • afterwards the folder calcardbackup-date inside the configured output directory (backupfolder) is being removed

The error you get is from tar which notices that the content of the folder calcardbackup-date is being modified while creating the archive (which of course has to result in an error). Is there any other program modifiying the content of that folder while my script is running?

Regarding your configuration question:

as long as you can open “https://ip.to.own.cloud” in a browser everything will be fine. In most use cases with modern owncloud versions (>=7.0) the URL is not needed anyway.

Another thing I noticed: you might want to change the rsync commands from (notice the change of slashes):
rsync -Aax /path/to/owncloud/data/ /path/to/external/storage
to
rsync -Aax /path/to/owncloud/data /path/to/external/storage/
to tidy up your backup directory a little bit. :slight_smile:


#10

The folder is located on my NAS Drive maybe this is indexing the files while tar is running? Nothing other is done to the calcardbackup backup directory.
Regarding the slashes I’m still confused about the usage :smiley:

PS.:
Just played around with the slashes and came to the conclusion that

cp /path/src /path/dest #copy the folder src and it's contents to dest
cp /path/src/ /path/dest #copy the contents of src to dest

#11

That could indeed be the case. Moving your script to the same folder than calcardbackup wouldn’t make a difference though.

You could create a local backup with calcardbackup and copy the archive to the NAS. calcardbackups option -b might be helpful then.


#12

Strange, I know ran the script again, got the same error, but a new archive…?
I don’t care about that archive, as long as the files are all there. Could I disable compression in the config?

PS.: Found the option to disable compression…
does encryption work without compression or is it just to encrypt the tar?
PPS.: It’s all in the README.md :smiley: :smiley: :smiley: