-
Notifications
You must be signed in to change notification settings - Fork 1
05 Data management
Make regular backup of the following.
- Sync database (logical or physical).
-
datadirdirectory.
Backup the following before and after their contents are modified.
-
confdirectory.
WARNING
- DO NOT attempt any of the below mentioned migration activities before creating a reliable backup of application data. Check backup section for more details.
- 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.
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.
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.
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 data-only SQL dump of source database excluding below mentioned tables. Use native database tools for the same.
cards_user
cards_system_user -
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).
-
Create SQL dump of only
cards_addressbooktable.
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 -
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
-
Create SQL dump of only
cards_addressbooktable.
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 -
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
-
Create SQL dump of only
cards_addressbooktable.
sqlite <syncdb_file> '.dump' | grep -i '^\s*INSERT\s\+INTO\s\+cards_addressbook' > ldap_carddav_syncdb_data_dump.sql -
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 the
ldap_carddav_syncdb_data_dump.sqlfile in target database. Use native database tools for the same. Examples are given below.
mysql -u <username> <dbname> < ldap_carddav_syncdb_data_dump.sql
psql --dbname <dbname> -c 'SET search_path TO <schema>' -f ldap_carddav_syncdb_data_dump.sql
sqlite <syncdb_file> < ldap_carddav_syncdb_data_dump.sql