monthly backup - solution with crontab

Backup, Restore, Netbak Replicator, Cloud Storage Services
Post Reply
FSC830
Experience counts
Posts: 2043
Joined: Thu Mar 03, 2016 1:11 am

monthly backup - solution with crontab

Post by FSC830 »

Hi,

As known by most of us the backup station provides in its schedule options the value „monthly“ which in combination with a day allows a monthly backup.
Unfortunately the power schedule of the NAS does not know an option „monthly“, only weekdays, weekend, daily or day of week (Monday to Sunday).
So only a weekly interval is possible.

Because of this very annoying mismatch me and another user in German QNAP forum created a workaround to match the both schedules for a monthly backup.

The reason behind this is that a lot of users have a second (or third, or even more...NAS) which is powered off and starts up only for the scheduled backup, afterwards it shuts down again.
You can use this script for any other monthly action too (i.e. raid scrubbing)

The scripts works without modifications if:

the schedule for power on/power off contains only exact these two entries (power on at first, power off at second)
or if the schedule contains more entries: power on must be at first, power off at second.

If power on/power off is at different position you need to modify the script or the schedule!

The power on day (day for monthly backup) is in the range 01...28.
The back schedule does not know an entry „first day“ or „last day“.
First day is always 01, but last day depends on month. So the common value for all months is 28.

A brief description is attached (dual language German/English).

The script is provided „as is“, use at your own risk.
The upload is a .zip file, containing the Linux script and the .pdf.

Any comments/feedback is welcome.

Regards

Edit 05.August 2019
Post updated with a new version, some minor bugfixes and more parameters.
An error in calculation fixed for months after July.
mpwron_v2.3.2.zip
Edit: to clarify:
This script does only allow one or more monthly power on/power off intervalls for specific tasks, i.e. a monthly backup, a monthly HDD check, a monthly raid scrub.
The task itself must be scheduled in QTS, this script is only for power on/power off times.
You do not have the required permissions to view the files attached to this post.
Last edited by FSC830 on Mon Aug 05, 2019 5:57 pm, edited 13 times in total.
P3R
Guru
Posts: 13192
Joined: Sat Dec 29, 2007 1:39 am
Location: Stockholm, Sweden (UTC+01:00)

Re: monthly backup - solution with crontab

Post by P3R »

In what cases do you want to run backups as selldom as monthly?

I do most backups every night and some weekly. I've never even considered doing any monthly as a lot of data is created and/or changed within a month.
RAID have never ever been a replacement for backups. Without backups on a different system (preferably placed at another site), you will eventually lose data!

A non-RAID configuration (including RAID 0, which isn't really RAID) with a backup on a separate media protects your data far better than any RAID-volume without backup.

All data storage consists of both the primary storage and the backups. It's your money and your data, spend the storage budget wisely or pay with your data!
Thisisnotmyname
Easy as a breeze
Posts: 447
Joined: Mon Nov 19, 2018 1:21 am

Re: monthly backup - solution with crontab

Post by Thisisnotmyname »

P3R wrote: Tue Jan 01, 2019 11:07 pm In what cases do you want to run backups as selldom as monthly?

I do most backups every night and some weekly. I've never even considered doing any monthly as a lot of data is created and/or changed within a month.

Probably a pretty limited use case. I suppose if someone has a tertiary (or more) backup to another NAS they have sitting around just doing so at very limited intervals and being able to keep it powered down ~29 days a month might make sense. Probably some situations in which you have monthly processes to back up too (i.e. end of month financial data).

Pretty edge cases though I'm sure.
FSC830
Experience counts
Posts: 2043
Joined: Thu Mar 03, 2016 1:11 am

Re: monthly backup - solution with crontab

Post by FSC830 »

This depends of course from the amount of data changed during such a period.
But there have been several requests from users to perform - in addition to their short term backups - at least a monthly backup to a dedicated NAS.
I did not say this is useful for everyone and for every scenario :wink: , it is just for those who want to do a monthly backup.

I am running the backups for my most important data hourly(!), daily and weekly to different NAS systems, but I am also using a dedicated NAS for a monthly backup which is not used for any other service.

By the way: a monthly backup is better than no backup :DD , you want believe how often the people claimed about their faulty NAS/disk and how to save the data... any question for a backup causes a deep silence... :shock:

Regards
P3R
Guru
Posts: 13192
Joined: Sat Dec 29, 2007 1:39 am
Location: Stockholm, Sweden (UTC+01:00)

Re: monthly backup - solution with crontab

Post by P3R »

FSC830 wrote: Wed Jan 02, 2019 7:30 pm By the way: a monthly backup is better than no backup...
A yearly backup would also be better than no backup but I fail to understand when either would be a good schedule.

Apparently you and others found that a weekly backup would be so wasteful that you needed to put in the effort here to produce a script. I asked for that use case but I guess I have to go on wondering.

If it's to have different generations of backups, Smart versioning will provide a much better spread of different backup generations.
...you want believe how often the people claimed about their faulty NAS/disk and how to save the data... any question for a backup causes a deep silence... :shock:
I've been promoting backups in this forum for more than 10 years and my signature below may also give a hint of that I'm aware of the backup situation for the average user.

Let's just hope that not any newbies around here think that monthly backups must be a good idea since someone felt the need to do this.
RAID have never ever been a replacement for backups. Without backups on a different system (preferably placed at another site), you will eventually lose data!

A non-RAID configuration (including RAID 0, which isn't really RAID) with a backup on a separate media protects your data far better than any RAID-volume without backup.

All data storage consists of both the primary storage and the backups. It's your money and your data, spend the storage budget wisely or pay with your data!
cochy
New here
Posts: 2
Joined: Wed Jul 29, 2020 12:13 am

Re: monthly backup - solution with crontab

Post by cochy »

Dear FSC830,

as I see the description, the script will power on the NAS and it will also power off.
What shall I change in the script, that it will only start the NAS but not to power off?
I have bigger disks and there are every month a lot of changes and as I see now, the NAS cannot finish the backup within one day. So I need a script which will only start the NAS and I will manually shut down after the backup finishes.
(I cannot start the NAS manually, because it is far from here).

Thank you.
dejanr
New here
Posts: 2
Joined: Sun Oct 08, 2017 6:03 am

Re: monthly backup - solution with crontab

Post by dejanr »

Thank you for this very useful script.

I use it to do backup every day except Saturday and Sunday. I use another to do separate backup on Saturday. That way if some ransomware strikes during the weekend, as they usually do because they need time to encrypt files, I still have a backup from Friday. And if it strikes on a working day, well, I have the backup from the last weekend.

I would not need to do this if QNAP have implemented useful option to save multiple versions of files, but I was unable to use it only on QNAP->QNAP backup. Not when backing up Windows Server.

Dejan
Post Reply

Return to “Backup & Restore”