L
L
lolowin322018-09-21 10:18:23
PostgreSQL
lolowin32, 2018-09-21 10:18:23

How to organize automatic backup of PostgreSQL databases via cron?

Good afternoon, to create a backup of Postgres databases, I use the command
pg_dump gitlab > /DATA/backups/gitlab`date +%d-%m-%Y`
Everything works the way I want, but if I put this command in cron, then after executing this command a message with information in /var/mail/postgres falls, with the error text
/bin/sh: 1: Syntax error: EOF in backquote substitution
I understand that something is wrong in the syntax, but how to fix this error? Thanks in advance for all the help

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Sergey Gornostaev, 2018-09-21
@lolowin32

We read man 5 crontaband see
That is, the percent sign in the cron configuration file is perceived as a newline character. To prevent this from happening, it must be escaped with a backslash.

pg_dump gitlab > /DATA/backups/gitlab`date +\%d-\%m-\%Y`

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question