Custom database backup

Operating system: Debian Linux
**OS version:**9

Hi everybody!

I’ve found under MySql database Server, that there is the option to backup all database.
Now: I’ve scheduled it, to make a backup every hour. But I’d like that every backup goes to specific directory that is called with the day/hour of that moment.

For example: if I’ve got a scheduled backup on 11 AM of 25 November, Virtualmin creates a directory (25-november-11-am, for example) and after this , he run the backup.

I’ve tried to add the syntax %D-%H (as you can see in the screenshot), but the created folder doesn’t contain day and hour in its name.

How it works? How I can do this?

1 Like

Did you enable this in the main DB config page? Gear icon, top left of main db page.
" Do Webmin variable substitution on backup destinations

I see " Do strftime substitution of backup destinations"

It’s the same?

That one also. I enable both those options.

Uhm ok.
So: I can leave in the backup path the syntax “%D-%H” and check these two boxes and it should work.
Right?

It works.

Only a small detail. In the setting “Backup to directory”, I’ve wrote this: “/backup_db/%d-%m-%y-%T”.

I’ve enabled the setting “Create destination directory” and enabled the options " Do Webmin variable substitution on backup destinations and " Do strftime substitution of backup destinations ".

The problem is that currently it creates 10 folders (I need only one folder with all db). Each folder contains one or more databases.

Put at / at the end of the path

1 Like

It doesn’t work. It still creates more folders.

In the next screen (where it shows the results of each backup ) the path is this:
“/backup_db/01-12-20-16:18:28//db_i10.sql.”

Double slash, lol.

I just backed up all my Db’s and it created 1 folder named 120120 and it put all DB’s in that one folder. Looks like the trailing slash is irrelevant.

And the settings page.

@asimpledeveloper

This is how I do it. make sure you have at installed [ apt-get install at ]

Uhm, it works, but my needs are different.

Currently, my folders are named like “01-12-2020 17:00:00” and “01-12-2020 17:00:01”, etc, with this in Backup to directory: “/backup_db/%d%m%y%T”

I wish the folders were named instead like this “01-12-2020 17:00” …
I’ve tried with /backup_db/%d%m%y%t … but without results.

You see the hour/minutes in folder name?

Have you actually tried the command?

Right here is the the full command list, so only add another %T for time and your sorted.


image

Hmmm, it is as simple as using not the %T but use the %R

image

Sorry for the delay.
Currently it works, but a detail.

I run the cron at minute 0 of each hour…the problem is that if the cron is running at the second 62 , Virtualmin creates another folder with “the new” minute.

I think that I’ll search an external solution…especially because I’d like to move the sql file to external storage…any idea on it?

Thanks again

Yeah, a typical programmers fault, testing at values, why don’t you try to run it at xx:05 insteadof xx:00
BTW our clock is having only 60 not 62, so if you say 62, do you assume we might think your cron job takes 62 seconds or 62 minutes? please give us more details. If it is running for 62 minutes then you will have an overlap so you have to change the frequence or give the process more priority, or simply use rsync because that is much faster.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.