[Solved] Command proxmox-backup-client doesn't work in cron

macromoon

Member
Aug 6, 2024
59
2
8
Hi, Colleagues!
I've already broken my head...

Start command on bash, all working:

Code:
root@pbs01:/# export PBS_PASSWORD=<token> && export PBS_USER_STRING='cifsbkp@pbs!backuptoken' && export PBS_SERVER=localhost && export PBS_DATASTORE=PBS_Backup_sql_day && export PBS_REPOSITORY="${PBS_USER_STRING}@${PBS_SERVER}:${PBS_DATASTORE}" && export path_temp=/mnt/sqlbkp_temp/ && proxmox-backup-client backup all_bak1c_day.pxar:${path_temp} --skip-lost-and-found
Starting backup: host/pbs01/2025-04-17T09:58:20Z
Client name: pbs01
Starting backup protocol: Thu Apr 17 12:58:20 2025
Downloading previous manifest (Wed Apr 16 14:06:28 2025)
Upload directory '/mnt/sqlbkp_temp/' to 'cifsbkp@pbs!backuptoken@localhost:8007:PBS_Backup_sql_day' as all_bak1c_day.pxar.didx
Cntr+C

If config in cron, then command doesn't working:

Code:
Apr 17 12:40:07 pbs01 crontab[164770]: (root) BEGIN EDIT (root)
Apr 17 12:40:33 pbs01 crontab[164770]: (root) REPLACE (root)
Apr 17 12:40:33 pbs01 crontab[164770]: (root) END EDIT (root)
Apr 17 12:40:40 pbs01 systemd[1]: Stopping cron.service - Regular background program processing daemon...
Apr 17 12:40:40 pbs01 systemd[1]: cron.service: Deactivated successfully.
Apr 17 12:40:40 pbs01 systemd[1]: Stopped cron.service - Regular background program processing daemon.
Apr 17 12:40:40 pbs01 systemd[1]: Started cron.service - Regular background program processing daemon.
Apr 17 12:40:40 pbs01 cron[164777]: (CRON) INFO (pidfile fd = 3)
Apr 17 12:40:40 pbs01 cron[164777]: (CRON) INFO (Skipping @reboot jobs -- not system startup)
Apr 17 12:42:01 pbs01 CRON[164791]: pam_unix(cron:session): session opened for user root(uid=0) by (uid=0)
Apr 17 12:42:01 pbs01 CRON[164791]: pam_unix(cron:session): session closed for user root
 
Cron usually uses sh rather than bash and $PATH is different. Might have something to do with it. Hard to tell with limited information. Can you share your cron file?
I'd strongly recommend you to put this into a nicely formatted bash script and call this instead of using that ugly one liner.
I'd also redirect the output to a file so you can see what happens.
 
Last edited:
  • Like
Reactions: waltar and Dark26
Cron usually uses sh rather than bash and $PATH is different. Might have something to do with it. Hard to tell with limited information. Can you share your cron file?
I'd strongly recommend you to put this into a nicely formatted bash script and call this instead of using that ugly one liner.
I'd also redirect the output to a file so you can see what happens.
Impact, thanks for response!

/etc/cron.daily/sqlbkp-for-tape :
Code:
#!/bin/sh
export PBS_PASSWORD=<token>
export PBS_USER_STRING='cifsbkp@pbs!backuptoken'
export PBS_SERVER=localhost
export PBS_DATASTORE=PBS_Backup_sql_day
export PBS_REPOSITORY="${PBS_USER_STRING}@${PBS_SERVER}:${PBS_DATASTORE}"
export path_temp=/mnt/sqlbkp_temp/
proxmox-backup-client backup all_bak1c_day.pxar:${path_temp} --skip-lost-and-found

- I'd strongly recommend you to put this into a nicely formatted bash script and call this instead of using that ugly one liner.

I use a script. It does not work. The rights are a+x on the file. The file name is without "." The last command proxmox-backup-client backup does not work ..... Apparently it requires user participation through the query interface and therefore is not executed through cron. If I run this script with && between each line, everything works. In cron, neither the script nor the command with && works.

Code:
# run-parts /etc/cron.daily/
Run pbs backup ...
Starting backup: host/pbs01/2025-04-16T10:52:58Z
Client name: pbs01
Starting backup protocol: Wed Apr 16 13:52:58 2025
No previous manifest available.
Upload directory '/mnt/sqlbkp_temp/' to 'cifsbkp@pbs!backuptoken@localhost:8007:PBS_Backup_sql_day' as all_bak1c_day.pxar.didx
all_bak1c_day.pxar: had to backup 151.126 MiB of 151.126 MiB (compressed 151.126 MiB) in 0.44 s (average 342.893 MiB/s)
Uploaded backup catalog (102 B)
Duration: 0.47s

- I'd also redirect the output to a file so you can see what happens.

File created, but log, unfortunately, empty.
32 10 * * * cd / && run-parts /etc/cron.daily >/root/log_cron
 
Last edited:
Try the full path to the executable (grab it via which proxmox-backup-client). You can also try to execute the script via bash -x script.sh.
 
Last edited:
  • Like
Reactions: macromoon
Try the full path to the executable (grab it via which proxmox-backup-client). You can also try to execute the script via bash -x script.sh.
edit /usr/bin/proxmox-backup-client backup ${SQLBKP_NAME}.img:${path_bak} --skip-lost-and-found


Code:
Apr 18 15:31:27 pbs01 crontab[185320]: (root) BEGIN EDIT (root)
Apr 18 15:31:35 pbs01 crontab[185320]: (root) REPLACE (root)
Apr 18 15:31:35 pbs01 crontab[185320]: (root) END EDIT (root)
Apr 18 15:31:40 pbs01 systemd[1]: Stopping cron.service - Regular background program processing daemon...
Apr 18 15:31:40 pbs01 systemd[1]: cron.service: Deactivated successfully.
Apr 18 15:31:40 pbs01 systemd[1]: Stopped cron.service - Regular background program processing daemon.
Apr 18 15:31:40 pbs01 systemd[1]: Started cron.service - Regular background program processing daemon.
Apr 18 15:31:40 pbs01 cron[185327]: (CRON) INFO (pidfile fd = 3)
Apr 18 15:31:40 pbs01 cron[185327]: (CRON) INFO (Skipping @reboot jobs -- not system startup)
Apr 18 15:32:01 pbs01 CRON[185344]: pam_unix(cron:session): session opened for user root(uid=0) by (uid=0)
Apr 18 15:32:01 pbs01 CRON[185345]: (root) CMD (cd / && run-parts /etc/cron.daily >/root/log_cron)
Apr 18 15:32:01 pbs01 CRON[185344]: pam_unix(cron:session): session closed for user root

log_cron = 0

but if i use in cron bash + x <script> all start! Great, thank's Impact!!!
 
Last edited: