postal icon indicating copy to clipboard operation
postal copied to clipboard

Backup/restore

Open jlnmrc opened this issue 6 years ago • 3 comments

I'm trying to write my backup procedure so that I can reinstall a postal server that is causing me too much trouble with slowness. Ideally, I want to keep the history and the global configuration and especially not to modify my DKIM DNS records (= keep the same default-dkim-record).

Does backing up

  1. all the postal-* databases
  2. the postal.yml file allow me to duplicate a postal server identically on a fresh installation?

jlnmrc avatar Jun 26 '20 09:06 jlnmrc

If you're using DigitalOcean, you can use their snapshot feature

navinp avatar Jun 26 '20 14:06 navinp

Backing up all the databases and the postal.yml file should be sufficient for most cases.

If you have made changes to the code, you will likely want to back those up yourself as well.

A full server snapshot is suitable if you're running all of Postal on one server.

If you are considering moving to a new server Postal can be run as a cluster so you can have multiple installations running if they are pointing at the same database and rabbitmq (and your DNS records have been updated as necessary). This means you could run both to allow you to be more graceful in your moving if necessary.

willpower232 avatar Jun 26 '20 14:06 willpower232

In case it helps anyone else... backup from a remote machine:

#!/bin/sh
HOSTNAME="postal.mydomain.com"
DATE=`date -I`

rsync -avzPe ssh root@$HOSTNAME:/opt/postal/config config-$DATE

USERNAME=$(yq -r .main_db.username config-$DATE/config/postal.yml)
PASSWORD=$(yq -r .main_db.password config-$DATE/config/postal.yml)

ssh root@$HOSTNAME \
  "docker exec postal-mariadb \
  mariadb-dump -u $USERNAME -p'$PASSWORD' --all-databases | gzip" > db-$DATE.sql.gz

gadicc avatar Oct 08 '25 13:10 gadicc