1.4. Maintenance

1.4.1. Backup

All data in Cyclos is stored in the database. Making a backup of the database can be done using the pg_dump command. The only file that you need to back-up (only once) will be the cyclos.properties configuration file. The database can be backed up manually as follows:

pg_dump --username=cyclos --password -hlocalhost cyclos4 > cyclos4.sql

Note: in this example the name of the database is cyclos4, the username cyclos and the command will prompt for the password of the cyclos user.

1.4.2. Restore

If you want to start using cyclos with the data from a backup. You can just import the backed up database. In this example the name of the database is cyclos4 the username cyclos and command will prompt for the password cyclos the name of the backup is cyclos4.sql make sure to specify the path if your not in the same directory as the file:

psql --username=cyclos --password -hlocalhost cyclos4 < cyclos4.sql

Note: in this example the name of the database is cyclos4, the username cyclos and command will prompt for the password cyclos, the name of the backup is cyclos4.sql (make sure to specify the path if your not in the same directory as the file).

1.4.3. Backup / restore of very large databases

When the database is very large (specially if it have a lot of images) it is possible to use a custom format for the dump file, which makes the dump file smaller. To use it, backup with the following command:

pg_dump --username=cyclos --password -Fc -hlocalhost cyclos4 > cyclos4.sql

To restore the dump, another command needs to be used as well:

pg_restore --username=cyclos --password -Fc -hlocalhost -d cyclos4 cyclos4.sql

1.4.4. Reset admin password directly on database

If you lost the password of your global administrator, it is still possible to update the value on database directly. To reset the password to 1234, run the following sql in the postgresql query tool (psql).

update passwords
set salt=null, value='$2a$10$yM.uw9jC7C1DrRGUhqUc3eSR6FCJH0.HdDt3CJs8YL56iATHcXH7.'
where user_id = (select id from users where username='admin')
and status = 'ACTIVE'
and password_type_id in (select id from password_types where input_method = 'TEXT_BOX' and password_mode = 'MANUAL');

Please make sure to replace the name 'admin' to the username used for the global administrator. Also a common mistake is that people forget to login as global administrator into the global url e.g. https://www.cyclos-domain/global.

1.4.5. Sending database to third parties

If Cyclos or a third party asks you to share the database with them it's vital for security that the passwords are removed from the database. The passwords in Cyclos can be hashed with one of the strongest algorithms available, but still passwords can be recovered using rainbow tables. If the database falls into the wrong hands some users might get compromised. Therefore it is always recommended to follow the following procedure before sharing the database with other parties:

  • Make a dump of the database (see Backup);
  • Restore the database in another (temporarily) database so the data can be changed without risking to change live data (see Restore);
  • Run the following command to reset all passwords to '1234':
    update passwords
    set value = '$2a$04$rDPKseEiJhYdjx9RogW2tuzNX4TKG1wcE79ooEXiA5.mJF.ooZY/2'
    where status <> 'OLD'
    and password_type_id in (
        select id
        from password_types
        where input_method = 'TEXT_BOX'
        and password_mode = 'MANUAL'
    );
  • It is also recommended to remove sensitive customer information from the database. For example all email addresses can be changed to a non existing email address as follows:
    update users
    set email = concat(username, '@test.com')
    where email is not null;
  • Then dump the database again. This file can then be sent to the third-party.