1
24.7 Production Series / Cron job with SCP
« on: September 16, 2024, 02:41:17 am »
I’m trying to create a cron job to backup my config and scp it to my backup server. I have the following script:
I have the following action file at
But running this with
What am I missing?
Code: [Select]
#!/bin/sh
DATE=`date +%d-%m-%Y_%H.%M.%S`
/usr/bin/bsdtar zcvhf /root/config_${DATE}.tar.gz -C / conf/config.xml conf/backup/ root/backup.sh
/usr/local/bin/scp -q /root/config_${DATE}.tar.gz hydrohs@my-ip:/data/hydrohs/Backups/opnsense/
rm /root/config_${DATE}.tar.gz
Running this script on its own works no problem.I have the following action file at
Code: [Select]
/usr/local/opnsense/service/conf/actions.d/actions_scp-backup.conf
With contentsCode: [Select]
[run]
command:/usr/local/opnsense/scripts/system/scp_backup.sh
type:script_output
message:Backing up config files
description:Backup config files
But running this with
Code: [Select]
configctl scp-backup run
doesn’t work (I have restarted configd), the archive does not get uploaded and I only get an entry like this is the configd log:Code: [Select]
[meta sequenceId="2"] [1c3d7ecc-6dc6-4003-a1ec-a7b5ecfbe2ff] Script action stderr returned "b'a conf/config.xml\na conf/backup\na conf/backup/config-1726428985.1454.xml\na conf/backup/config-1726427955.1602.xml\na conf/backup/config-1726430341.1865.xml\na conf/backup/config-1726430899.0235.xml\na conf/backup/config-1726428942.926.xml\na conf/backup/confi'"
What am I missing?