Automated backup?

General support for the Pi-Star System
Post Reply
g6nhu
Posts: 14
Joined: Thu Oct 31, 2019 3:31 pm

Automated backup?

Post by g6nhu »

I don't need to restore from a backup very often but it's occurred to me that I don't take a backup of my Pi-Star hotspots often enough.

I see that the backup is triggered from within /var/www/dashboard/admin/config_backup.php but is there an easy way I can kick this off via cron with the output file being sent to a network share? Ideally I'd use cron to run a script which runs the backup to my NAS and then checks the NAS and removes files older than a set period. I can do all the other bits, it's just working out how to run a backup via a script that's bugging me.

If I tweak /var/www/dashboard/config/language.php with the full path to the lang folder, I can manually run 'php config_backup.php' from the terminal which completes but with no apparent file being created (yes, I have made the file system read-write).

I can see when I click to make a backup from the GUI, it creates a backup directory in /tmp which it then zips prior to renaming and downloading. If I can persuade the system to create that zip file from the terminal then I'm sorted.

Any suggestions please?

73 Keith.
User avatar
YL3IM
Posts: 40
Joined: Sun Nov 22, 2020 8:38 pm
Location: Riga, Latvia
Contact:

Re: Automated backup?

Post by YL3IM »

Why do you need the GUI frontend? Use a shell script instead, like this one:

Code: Select all

#!/bin/bash

backupDir="/tmp/Pi-Star_Config_${HOSTNAME}_`date +%d-%b-%Y`"
backupZip="${backupDir}.zip"

mkdir -p ${backupDir}

cp -r \
/etc/wpa_supplicant/wpa_supplicant.conf \
/etc/ircddbgateway \
/etc/mmdvmhost \
/etc/dstarrepeater \
/etc/dapnetgateway \
/etc/p25gateway \
/etc/ysfgateway \
/etc/nxdngateway \
/etc/ysf2dmr \
/etc/dmrgateway \
/etc/mobilegps \
/etc/starnetserver \
/etc/timeserver \
/etc/dstar-radio.* \
/etc/pistar-remote \
/etc/hosts \
/etc/hostname \
/etc/bmapi.key \
/etc/dapnetapi.key \
/usr/local/etc/RSSI.dat \
/var/www/dashboard/config/ircddblocal.php \
/var/www/dashboard/config/config.php ${backupDir}

zip -j ${backupZip} ${backupDir}/*

# Insert here your code below to transfer the file whenever you need to:

# This deletes the backup to save space:
rm -fr ${backupDir}*
g6nhu
Posts: 14
Joined: Thu Oct 31, 2019 3:31 pm

Re: Automated backup?

Post by g6nhu »

YL3IM wrote: Mon Dec 28, 2020 12:57 pm Why do you need the GUI frontend?
I don't, I was using that as an example to show that I'd actually done some work and tried to find out where the backup was called from and wondering whether it would be possible to invoke it that way somehow.

I'll use what you've posted as a basis for my shell script, thank you.
Post Reply