BernieO / calcardbackup

calcardbackup: moved to https://codeberg.org/BernieO/calcardbackup
GNU Affero General Public License v3.0
69 stars 5 forks source link

doesn't backup "old" calendars #20

Closed sizzlingapple closed 5 years ago

sizzlingapple commented 5 years ago

Infos: Ubuntu 18.04 Server User are synched from LDAP Server Nextcloud 15.0.5 (just updated from 15.0.2 didn't work there neither) MariaDB 10.1.38

Problem: Doesn't backup calendars of existing users/calendars. Backup of admin calendar works without a problem, it also sees the users (I assume) because of the empty adressbook it finds.

Tests: If I create a new calendar within a user it sees it "...test-cal-shared.ics" If I create a new user in LDAP and then create a calendar it also works "...Jodl.ics" script is executed with "sudo -u www-data ./calcardbackup "/var/www/nextcloud" also tried with "sudo -u www-data ./calcardbackup "/var/www/nextcloud -u users.txt -z" "sudo -u www-data ./calcardbackup "/var/www/nextcloud -u users.txt -i"

+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ +

BernieO commented 5 years ago

Unfortunately, I am not very experienced with ldap. I just installed a ldap-server to one of my testing instances, but could not reproduce the issue. I need your help to debug.

I am taking user cb3e0866-d5b6-1037-8478-fb9428484cf6 as example, as it looks like it is one of the users, where the problem occurs (of course you could choose another user, if you prefer).

Do you have access to the Nextcloud database? Could you:

  1. verify that there is at least one calendar in the nextcloud calendar app from user cb3e0866-d5b6-1037-8478-fb9428484cf6?
  2. post a line from table [PREFIX]calendars where in field principaluri the value [ANOTHER_PREFIX]cb3e0866-d5b6-1037-8478-fb9428484cf6 is found. [ANOTHER_PREFIX] is usually principals/users/, but I suspect this might be different for existing ldap-users. Note value id of that line which is needed for step-3.
  3. verify, that in table [PREFIX]calendarobjects there are entries where calendarid is matching the id from the line of step-2. Could you posts the value of the field calendardata from one of those lines?

Of course you should anonymize data (or create a new calendar/-entry with dummy values)

sizzlingapple commented 5 years ago

Im not really good with databases but I tried to get the stuff you need, if its wrong i'l try again :) one

tow_three

Of course you should anonymize data (or create a new calendar/-entry with dummy values) The weird thing is that if I create a new calendar I don't have the problem even with the same user from ldap.

BernieO commented 5 years ago

I need to compare the database entries from a newly created calendar (which is found by calcardbackup) and an old calendar (which is not found by calcardbackup) from the very same user of ldap.

Therefore, could you create a new calendar for this user and post the output of this mysql-command:

SELECT calendarcolor, id, principaluri, uri, displayname FROM ncu_calendars WHERE principaluri = 'principals/users/cb3e0866-d5b6-1037-8478-fb9428484cf6'; 

It would be best to post the output as a code block with triple backticks (to make sure that there are no linebreaks in the mysql result)

sizzlingapple commented 5 years ago

"sudo -u www-data ./calcardbackup "/var/www/nextcloud"

+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+
+  Mon Apr  1 20:55:27 UTC 2019 --> START calcardbackup ver. 0.8.7 (20.03.2019), AGPL-3.0
+  Checking dependencies and preparing...
+  no usersfile given: will backup all available items
+  
+  Using URL: https://example.org
+  no valid status.php found at https://example.org.
+  Nextcloud 15.0.5 detected.
+  Database of chosen Nextcloud installation is MySQL/MariaDB.
+  Looking for calendars in your Nextcloud:
+  saving calendar REDACTED-Personal.ics (from database)......success!
+  saving calendar 5186a584-55b1-1038-9c51-b125d912bbcd-Jodl.ics (from database)......success!
**+  saving calendar cb3e0866-d5b6-1037-8478-fb9428484cf6-calcardbackup-test.ics (from database)......success!**
+  Looking for calendarsubscriptions in your Nextcloud:
+  No calendarsubscriptions found.
+  Looking for addressbooks in your Nextcloud:
+  saving addressbook REDACTED-Contacts.vcf (from database)......empty file. Addressbook 'Contacts' of user 'REDACTED' is empty.
+  saving addressbook cb3e0866-d5b6-1037-8478-fb9428484cf6-Contacts.vcf (from database)......empty file. Addressbook 'Contacts' of user 'cb3e0866-d5b6-1037-8478-fb9428484cf6' is empty.
***
SAME MESSAGE
***
+  saving addressbook 5d766aba-a5bb-1037-8940-e3222c59b1f9-REDACTED.vcf (from database)......success!
+  Compressing backup as *.tar.gz file. Be patient - this may take a while.
+  Backup successfully compressed!
+  Find your backup here: /backup/calcardbackup/backups/calcardbackup-2019-04-01.tar.gz
+  Mon Apr  1 20:55:29 UTC 2019 --> END calcardbackup
+
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

SELECT calendarcolor, id, principaluri, uri, displayname FROM oc_calendars WHERE principaluri = 'principals/users/cb3e0866-d5b6-1037-8478-fb9428484cf6';

thanks for the help with the sql query
SELECT calendarcolor, id, principaluri, uri, displayname FROM oc_calendars WHERE principaluri = 'principals/users/cb3e0866-d5b6-1037-8478-fb9428484cf6'; 
+---------------+----+-------------------------------------------------------+--------------------+--------------------+
| calendarcolor | id | principaluri                                          | uri                | displayname        |
+---------------+----+-------------------------------------------------------+--------------------+--------------------+
| #CC317C       | 26 | principals/users/cb3e0866-d5b6-1037-8478-fb9428484cf6 | calcardbackup-test | calcardbackup-test |
| #9DA6A8FF     |  4 | principals/users/cb3e0866-d5b6-1037-8478-fb9428484cf6 | personal           | REDACTED                |
+---------------+----+-------------------------------------------------------+--------------------+--------------------+
2 rows in set (0.00 sec)
BernieO commented 5 years ago

Thanks, I think I found the problem: the calendarcolor of the personal-calendar looks like it has to many characters (it should be #RRGGBB, but it is #RRGGBBXX).

Commit ba6af7973374b2e628624d2a34189167b7cec576 makes calcardbackup tolerate calandercolors with more (or less) than 7 characters. This is also what sabre-davs calendar-export function does.

Can you check whether ba6af7973374b2e628624d2a34189167b7cec576 solves the issue for you?

sizzlingapple commented 5 years ago

thanks the fix works perfectly. All calendars are seen. The issue is solved.

Any way I can donate to you for a beer or coffee?

BernieO commented 5 years ago

Fixed in v0.8.8

Any way I can donate to you for a beer or coffee?

Thanks that is very kind of you, but not necessary. I appreciate it!