Operate user: barman
If run these 2 commands, it can work:
/usr/bin/barman cron
/usr/bin/barman backup pg
Set them to crontab:
crontab -e
* * * * * /usr/bin/barman cron
0 4 * * * /usr/bin/barman backup pg
Crontab service status:
systemctl status crond
● crond.service - Command Scheduler
Loaded: loaded (/usr/lib/systemd/system/crond.service; enabled; vendor preset: enabled)
Active: active (running) since Fri 2020-02-21 10:40:58 JST; 2 weeks 0 days ago
Main PID: 23099 (crond)
CGroup: /system.slice/crond.service
└─23099 /usr/sbin/crond -n
Localtime:
ls -l /etc/localtime
lrwxrwxrwx 1 root root 32 Mar 26 2019 /etc/localtime -> ../usr/share/zoneinfo/Asia/Tokyo
But it didn't run backup at 4 o'clock today. Why?
Add Test
Tested:
40 18 * * * /usr/bin/barman cron
41 18 * * * /usr/bin/barman backup pg
See log:
less /var/log/cron
...
Mar 6 18:40:02 server crond[23099]: (barman) RELOAD (/var/spool/cron/barman)
Mar 6 18:40:02 server CROND[13013]: (barman) CMD (/usr/bin/barman cron)
Mar 6 18:40:02 server CROND[13014]: (barman) CMD ( [ -x /usr/bin/barman ] && /usr/bin/barman -q cron)
Mar 6 18:40:02 server CROND[13015]: (root) CMD (/usr/lib64/sa/sa1 1 1)
Mar 6 18:41:01 server CROND[13117]: (root) CMD (/usr/lib64/sa/sa1 1 1)
Mar 6 18:41:01 server CROND[13119]: (barman) CMD ( [ -x /usr/bin/barman ] && /usr/bin/barman -q cron)
Mar 6 18:41:01 server CROND[13118]: (barman) CMD (/usr/bin/barman backup pg)
It seems the task started, but didn't backup database. If run /usr/bin/barman backup pg
can do.
There has to be a new line after the last command. If you look at
/var/log/cron
or wherever your cron logs are kept, you'll see an error indicating this.To get the job to run, go into
crontab -e
and pressENTER
at the end of the last line so that the cursor is on the next line and then save it. The last job will then run.