Skip to content

05 Data management

Shubhra Prakash Nandi edited this page May 30, 2026 · 33 revisions

Backup

Data

Make regular backup of the following.

  1. Sync database (logical or physical).
  2. datadir directory.

Configuration

Backup the following before and after their contents are modified.

  1. conf directory.

Migration

WARNING

  1. DO NOT attempt any of the below mentioned migration activities before creating a reliable backup of application data. Check backup section for more details.
  2. DO NOT attempt any of the below mentioned migration activities while the application is online as it may result in data corruption and/or data inconsistency.

Data directory

Move the directory pointed to by datadir configuration key in the conf file to new location. Update datadir configuration key in the conf file to new location.

Cache directory

Move the directory pointed to by cachedir configuration key in the conf file to new location. Update cachedir configuration key in the conf file to new location.

Sync database

The below mentioned steps can be used to migrate existing sync database data (source database) to a target sync database containing compatible database structure and column types with source database.

Create SQL dump

  1. Create data-only SQL dump of source database excluding below mentioned tables. Use native database tools for the same.
    cards_user
    cards_system_user

  2. In case you cannot disable foreign key enforcement in the target database during load you, as an example, can create the SQL data dump in a file called ldap_carddav_syncdb_data_dump.sql (in the current directory) as below to load the data in the target database without getting foreign key violation error(s).

MariaDB / Mysql

  1. Create SQL dump of only cards_addressbook table.
    mysqldump --skip-triggers --no-create-info --no-create-db --single-transaction --complete-insert --skip-set-charset --skip-extended-insert --skip-opt --compact --quick --hex-blob --compatible=ansi --skip-quote-names -u <username> <dbname> cards_addressbook | grep -i '^\s*INSERT\s\+INTO\s\+' > ldap_carddav_syncdb_data_dump.sql

  2. Create SQL dump of rest of the needed tables.
    mysqldump --skip-triggers --no-create-info --no-create-db --single-transaction --complete-insert --skip-set-charset --skip-extended-insert --skip-opt --compact --quick --hex-blob --compatible=ansi --skip-quote-names --ignore-table <dbname>.cards_addressbook --ignore-table <dbname>.cards_user --ignore-table <dbname>.cards_system_user -u <username> <dbname> | grep -i '^\s*INSERT\s\+INTO\s\+' >> ldap_carddav_syncdb_data_dump.sql

PostgreSQL

  1. Create SQL dump of only cards_addressbook table.
    pg_dump --format plain --data-only --no-owner --no-privileges --large-objects --inserts --column-inserts --no-comments --no-publications --no-sync --no-tablespaces --no-table-access-method --table <schema>.cards_addressbook --dbname <dbname> | grep -i '^\s*INSERT\s\+INTO\s\+' > ldap_carddav_syncdb_data_dump.sql

  2. Create SQL dump of rest of the needed tables.
    pg_dump --format plain --data-only --no-owner --no-privileges --large-objects --inserts --column-inserts --no-comments --no-publications --no-sync --no-tablespaces --no-table-access-method --exclude-table <schema>.cards_addressbook --exclude-table <schema>.cards_user --exclude-table <schema>.cards_system_user --dbname <dbname> | grep -i '^\s*INSERT\s\+INTO\s\+' >> ldap_carddav_syncdb_data_dump.sql

SQLite

  1. Create SQL dump of only cards_addressbook table.
    sqlite <syncdb_file> '.dump' | grep -i '^\s*INSERT\s\+INTO\s\+cards_addressbook' > ldap_carddav_syncdb_data_dump.sql

  2. Create SQL dump of rest of the needed tables.
    sqlite <syncdb_file> '.dump' | grep -i '^\s*INSERT\s\+INTO\s\+' | grep -iv '^\s*INSERT\s\+INTO\s\+\(cards_addressbook\|cards_user\|cards_system_user\)\s\+' >> ldap_carddav_syncdb_data_dump.sql

Load SQL dump

  1. Load the ldap_carddav_syncdb_data_dump.sql file in target database. Use native database tools for the same. Examples are given below.

MariaDB / Mysql

mysql -u <username> <dbname> < ldap_carddav_syncdb_data_dump.sql

PostgreSQL

psql --dbname <dbname> -c 'SET search_path TO <schema>' -f ldap_carddav_syncdb_data_dump.sql

SQLite

sqlite <syncdb_file> < ldap_carddav_syncdb_data_dump.sql

Clone this wiki locally