daily backup script?

General discussion about Gargoyle, OpenWrt or anything else even remotely related to the project

Moderator: Moderators

Post Reply
pkkrusty
Posts: 42
Joined: Mon Jan 13, 2020 4:41 pm

daily backup script?

Post 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.

Lantis
Moderator
Posts: 6666
Joined: Mon Jan 05, 2015 5:33 am
Location: Australia

Re: daily backup script?

Post 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.
http://lantisproject.com/downloads/gargoyle_ispyisail.php for the latest releases
Please be respectful when posting. I do this in my free time on a volunteer basis.

pkkrusty
Posts: 42
Joined: Mon Jan 13, 2020 4:41 pm

Re: daily backup script?

Post by pkkrusty »

Entire configuration

Lantis
Moderator
Posts: 6666
Joined: Mon Jan 05, 2015 5:33 am
Location: Australia

Re: daily backup script?

Post 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.
http://lantisproject.com/downloads/gargoyle_ispyisail.php for the latest releases
Please be respectful when posting. I do this in my free time on a volunteer basis.

pkkrusty
Posts: 42
Joined: Mon Jan 13, 2020 4:41 pm

Re: daily backup script?

Post by pkkrusty »

Awesome thanks!

pkkrusty
Posts: 42
Joined: Mon Jan 13, 2020 4:41 pm

Re: daily backup script?

Post 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

Lantis
Moderator
Posts: 6666
Joined: Mon Jan 05, 2015 5:33 am
Location: Australia

Re: daily backup script?

Post 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.
http://lantisproject.com/downloads/gargoyle_ispyisail.php for the latest releases
Please be respectful when posting. I do this in my free time on a volunteer basis.

Post Reply