Kasm uses Postgres as the backend database. This section covers backup and restoration of the Kasm database.
The following script will backup the Postgres data and all conf files to a single file.
# this will place the back at /tmp/backup.tar sudo docker exec kasm_db pg_dump -U kasmapp -F t kasm > /tmp/backup.tar
This can be scripted out in a cron job, for example daily, with the date in the filename of the tar file for historical backups. Change the /tmp to a directory that is using an NFS mount so the files are stored off the server.
The following script will restore the database from backup. This example assumes the server is just the datebase role, however, this process will work just as well on a system where all roles are installed.
# download the same version of kasm that is on the primary database server and unpack it tar -xf kasm_release*.tar.gz # install just the database component sudo bash kasm_release/install.sh -b # copy the backup.tar into the kasm_db container sudo docker cp backup.tar kasm_db:/tmp/backup.tar # restore the database sudo docker exec kasm_db pg_restore -d kasm /tmp/backup.tar -c -U kasmapp
If you restore to a different server you will need to change the database IP or hostname that is referenced by all API and Manager systems. You can avoid this using several methods. Use a hostname and change the IP address in your DNS record. This may take up to an hour to propogate depending on the TTL setting of the DNS record. Use a 5 minute TTL if possible. The other method is to use a virtual IP address if you have a router or firewall inbetween your database servers and the manager/api components. Finally, you can use NGINX with layer 4 load balancing. You can back one backend server as back in the upstream definition in nginx.