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.
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).
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
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.
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:
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'
);update users set email = concat(username, '@test.com') where email is not null;