Backup and Restore

Backup#

Create backup file instamate.bck:

docker-compose exec -T database pg_dump -U instamate instamate > /backuplocation/instamate.bck
note

-T is important if you add this line in a crontab else the backup will not work because docker will generate this error the input device is not a TTY

note

Be absolutely certain to move the instamate.bck file to another safe location, as you may loose that backup file if you use a docker-compose GUI to upgrade your InstaMate configuration. Some GUIs delete the folder that holds the docker-compose.yml when updating.

note

If you get the error No such service: database, update your docker-compose.yml or use db instead of database in the above command.

Restore#

note

Replace the default instamate value below with the value defined in the env file if you have one

# Stop the teslamate container to avoid write conflicts
docker-compose stop instamate
# Drop existing data and reinitialize
docker-compose exec -T database psql -U instamate << .
drop schema public cascade;
create schema public;
.
# Restore
docker-compose exec -T database psql -U instamate -d instamate < instamate.bck
# Restart the teslamate container
docker-compose start instamate