Page 1 of 1

daily backup script?

Posted: Tue Oct 11, 2022 10:19 am
by pkkrusty
I did some searching but the search function ignores the word "script" so nothing came up. Is there a handy script/cron already written to make a backup every x hours and save to an attached USB drive? I assume this would occur in crontab, but I'm mostly familiar with Debian and router command line structure is a bit foreign to me.

Re: daily backup script?

Posted: Wed Oct 12, 2022 12:44 am
by Lantis
What do you want to backup?
There are backup scripts for BW and Quota data already written that write to /usr/data and /tmp/data, which would be a great template to start.
Do you want to backup the entire configuration? There's a script for that too which could be used as a base.

Re: daily backup script?

Posted: Wed Oct 12, 2022 1:58 am
by pkkrusty
Entire configuration

Re: daily backup script?

Posted: Thu Oct 13, 2022 4:22 am
by Lantis
Use the existing script
https://github.com/ericpaulbishop/gargo ... _backup.sh

Code: Select all

sh /usr/lib/gargoyle/create_backup.sh
Then download/transfer the file from /tmp/backup/backup.tar.gz and delete it after.

Re: daily backup script?

Posted: Sat Oct 15, 2022 3:51 am
by pkkrusty
Awesome thanks!

Re: daily backup script?

Posted: Sat Oct 15, 2022 7:03 am
by pkkrusty
OK, so what I would do is edit the root crontab to execute that default script every x amount of time.

But I'll need to adjust the script to copy the backup file to the USB drive then rename it to include datetime in the filename.

Can you give me some hints on the syntax for that? Or a google search phrase that will get me started?

something like:

Code: Select all

mv /tmp/backup/backup.tar.gz /mnt/backup_$(date +"%FT%H%M".tar.gz

Re: daily backup script?

Posted: Sat Oct 15, 2022 6:39 pm
by Lantis
Yes something like that. I’d use
"$(date +%Y%m%d_%H%M%S)".tar.gz

Your usb drive should have a mount point under /tmp/usb_mount/ as well.

My advice is to not modify the original script as that is part of Gargoyle functionality.
Instead write another script called “mybackup.sh” that does 2 things:
1. Calls the gargoyle backup script
2. Moves the file to your usb drive

Then use cron to execute that one.