Automating TimescaleDB Backups: A Guide

Automating TimescaleDB Backups: A Guide

Profile picture for user LukasVileikis
Lukas Vileikis
22 April 2021

If you have ever used TimescaleDB, you have probably backed up your data. And if you have ever backed up your data, you have probably thought about how you should automate these processes.

How do Backups in TimescaleDB Work?

Backing up TimescaleDB takes advantage of functionality that is already available in PostgreSQL: in PostgreSQL, physical backups can be taken with pg_basebackup, logical backups can be taken with pg_dump and pg_restore. For example, to backup a database called demo_database, you can run the following using pg_dump:

pg_dump -Fc -f demo_database.bak demo_database

Replace demo_database.bak with your file name and demo_database with your database name.

How do You Automate TimescaleDB Backups?

To automate TimescaleDB backups you have a couple options: one of them is to use software specifically designed for the task. We will now look into how you should go about automating TimescaleDB backups with Backup Ninja. Backup Ninja allows you to create logical and physical backups using a centralised console and restore them to any location with just a few clicks. To start automating TimescaleDB backups, simply click on TimescaleDB on the Backup Target page:

Backup Target

First, fill in the details - select the database server you want to backup, select the schedule name and the backup method:


Then, define where you want to store your backups - define your backup directory, retention policy and choose for how many days you want to store backups:

Backup Storage

Then choose a name pattern:


Finally, select when you want the backup to run - make a backup schedule. Your backup procedure can either run minutely, hourly, daily, weekly, monthly, or, if you so desire, even yearly:

Scheduling Backups

Click Schedule Backup and that’s it - you’re done!


Automating your TimescaleDB backup processes really isn’t as hard as it might seem from first glance. In this space, tools like Backup Ninja can be your savior - to put Backup Ninja to good use when automating your TimescaleDB backups, follow this guide and you should be well on your path to automating all of your TimescaleDB backup processes. If you need some more help, skim through Backup Ninja’s documentation.