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 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 are hashed with one of the strongest algorithms available, but still passwords can be theoretically recovered using brute force (although very unlikely). If the database falls into the wrong hands some users might get compromised. Therefore it is always recommended to follow this 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;
A common practice for a first-time configuration of Cyclos, specially with a complex structure for accounts, configurations, products and groups, is to configure all the system, and create some test users and payments. However, after finishing configuration, it might be desirable to remove all users and transfers (payments) from that network, leaving only administrators and configurations. Alternatively, it might be desirable to completely delete an entire network.
Starting with Cyclos 4.11, an interactive utility is included in Cyclos, which can be used for both cases. Please, be advised to perform a full database dump before running the utility, and have Cyclos stopped before running it. To run the utility, go to the <TOMCAT_DIR>/webapps/<cyclos_dir> directory and execute:
java -cp "WEB-INF/classes:../../lib/*:WEB-INF/lib/*" \
org.cyclos.db.DeleteNetworkDataThen follow the instructions presented on the console. When a a lot of data is removed, it might be desirable to run a full vacuum in the database. This operation might take a while. An example on how to run it is:
$ vacuumdb --full $DATABASE_NAME