Upgrades and Backups
Each DocSpring Enterprise release is a new image version, and the DocSpring Enterprise releases page lists them with their notes. We also email the notes to your license contacts.
Upgrade
Section titled “Upgrade”- Read the release notes of the new version, and of every version between it and yours. The Upgrade notes section says if a release needs anything from you, such as a new setting.
- Back up your database and Redis, and your files if they’re on the server rather than in a bucket (below).
- Run the release command with the new image:
run_as_deploy rake db:prepare. It runs the release’s database migrations. Your current services keep working while it runs. - Restart every service on the new image, and point your scheduled tasks at it.
You can skip releases: the release command runs every migration between your version and the new one.
Our deployment configs do steps 3 and 4 in the right order:
| Platform | Upgrade with |
|---|---|
| Docker Compose | ./update.sh <version>, which also backs up the database first |
| Kubernetes | helm upgrade with the new image.tag: the release command is a hook that runs before the pods change |
| AWS ECS | Set image_tag, terraform apply, then scripts/deploy |
| Convox | Change the version on the image: lines in convox.yml, then ./update.sh |
| Aptible | Change the version in the Dockerfile’s FROM line, commit and git push aptible main |
Back up
Section titled “Back up”DocSpring keeps its data in PostgreSQL and in its file storage, and its job queues in Redis. Back up all three, and keep these settings somewhere safe and separate from the backups:
DOCSPRING_SUBMISSION_DATA_ENCRYPTION_KEY, without which the submission data in a backup can’t be read.SECRET_KEY_BASE, which signs sessions and links.
The database: use your managed database’s automated backups and point-in-time recovery (Amazon RDS, Cloud SQL and
Azure keep them for as long as you choose), or run pg_dump on a schedule:
pg_dump --format=custom --no-owner "$DATABASE_URL" > docspring-$(date +%Y%m%d).dumpFiles: turn on versioning for your S3 or Google Cloud Storage bucket, so a file that’s deleted or overwritten by
mistake can be restored. Files kept on the server (the Docker Compose uploads volume) need their own backup.
Redis: a submission that’s waiting for its PDF, an email or a webhook has a job in Redis. Restore a database
without its queues and those submissions stay pending. Back up Redis with the database, with the worker service
stopped: it takes a job off the queue when it runs it, so a job that finished between the two backups would leave a
pending submission with no job. Stop worker, back up the database, save a copy of Redis with redis-cli --rdb (or
take a snapshot of your managed Redis), then start worker again. On a stop, it finishes or puts back the jobs it’s
running, and the web service keeps working: jobs wait in the queue meanwhile.
The Docker Compose setup’s backup.sh saves the database, Redis and the uploads volume, and its
README restores them.
To restore, load the dump into an empty database with pg_restore --no-owner --dbname "$DATABASE_URL", restore the
files and Redis from the same time, and start DocSpring with the same encryption key and SECRET_KEY_BASE.
Go back to the previous release
Section titled “Go back to the previous release”Our database migrations keep the previous release working: they add tables and columns but don’t remove the ones it uses. So if something goes wrong after an upgrade, deploy the version you were running before, without restoring the database. Tell us what happened, at support@docspring.com.
Going back further than one release, or a problem with the data itself, may need the backup you took before the upgrade. Contact us first.