Community discussions

MikroTik App
 
User avatar
stmx38
Long time Member
Long time Member
Topic Author
Posts: 650
Joined: Thu Feb 14, 2008 4:03 pm
Location: Moldova, Chisinau

Dude v6 - Backup locally

Sun Jul 16, 2017 7:26 pm

Dude v6 - Backup locally

Requirements
Dude v6 and above

Note: Please be aware, Dude is stopping during database export/import!

Configuration
1. Create a script.
System --> Scripts:
Name: backup-dude-locally
Policy: ftp, read, write, test
Source:
#
# Backup Dude locally
#
# Define variables
:local dudeconffilename "Dude_configuration_backup"
:local dudedbfilename "Dude_db_backup"
:local dudeconffileext "rsc"
:local dudedbfileext "db"
:local localbackuppath "disk1"
#
# Get date and time
#
{
:local curDate [/system clock get date]
:local curTime [/system clock get time]
:local systemName [/system identity get name]
:local curMonth [:pick $curDate 0 3]
 :set curMonth ( [ :find key="$curMonth" in="jan,feb,mar,apr,may,jun,jul,aug,sep,oct,nov,dec" from=-1 ] / 4 + 1)
 if ( $curMonth < 10 ) do={
  :set curMonth ( "0".$curMonth )
 } else={
  :set curMonth $curMonth
 }
:local curDay   [:pick $curDate 4 6]
:local curYear  [:pick $curDate 7 13]
:local curHour  [:pick $curTime 0 2]
:local curMin   [:pick $curTime 3 5]
:local now ("$curYear"."$curMonth"."$curDay" ."-"."$curHour"."$curMin")
#
# Make Dude backup
#
:log warn message="Dude backup locally started";
/dude export file="$localbackuppath/$dudeconffilename_$now.$dudeconffileext"
/dude export-db backup-file="$localbackuppath/$dudedbfilename_$now.$dudedbfileext"
:log warn message="Dude backup locally finished";
#
}
Dude-v6-Backup-locally-01-Script.png
2. Create a schedule.
System --> Scheduler:
Name: backup-dude-locally
Start Day: Nov/07/2017
Start Time: 02:00:00
Interval: 1d 00:00:00
Policy: ftp, read, write, test
On Event: dude-backup-locally
Dude-v6-Backup-locally-02-Schedule.png
3. See the result
Files
Dude-v6-Backup-locally-03-Files.png

Restore backup
In case of need, you can restore Dude v6 from recently created backup:
/dude set enabled=no
/import disk1/Dude_configuration_backup_20170716-0200.rsc
/dude import-db backup-file=disk1/Dude_db_backup_20170716-0200.db
/dude set enabled=yes

Used materials
1. Export to File - Filename Variable
2. Manual:The Dude v6/DB import export

Related solutions
1. Dude v6 - Backup to FTP
You do not have the required permissions to view the files attached to this post.
Last edited by stmx38 on Fri May 05, 2023 6:02 am, edited 1 time in total.
 
excession
Member Candidate
Member Candidate
Posts: 122
Joined: Mon May 11, 2015 8:16 pm

Re: Dude v6 - Backup locally

Thu Aug 16, 2018 5:12 pm

This saved me a lot of time, thanks for sharing.
 
simogere
Frequent Visitor
Frequent Visitor
Posts: 56
Joined: Fri May 24, 2013 11:54 am

Re: Dude v6 - Backup locally

Wed Jan 04, 2023 1:11 am

Hi @stmx38, thanks for the tips.

A simple question:

Image

Why the backup db is half the size of the original db?
 
User avatar
stmx38
Long time Member
Long time Member
Topic Author
Posts: 650
Joined: Thu Feb 14, 2008 4:03 pm
Location: Moldova, Chisinau

Re: Dude v6 - Backup locally

Thu Jan 05, 2023 6:37 am

Hello @simogere, I'm out of the topic now and can't reproduce and check it.

Can it be related to the DB vacuum effect?
Manual:The Dude v6/DB import export does not provide so much details.

If you have an assumption that you lose some data, probably it can be better to restore that backup on another device and check if all is in place.
 
User avatar
voljka
newbie
Posts: 44
Joined: Tue Oct 27, 2009 4:34 pm

Re: Dude v6 - Backup locally

Sat Nov 02, 2024 7:12 pm

On my RB with v7 date has following format:
[admin@R0B] > /system/clock/print
time: 19:07:22
date: 2024-11-02
time-zone-autodetect: yes
time-zone-name: Europe/Riga
gmt-offset: +02:00
dst-active: no

So, backup filename looks not correct. Can anybody adapt original script to 2024-11-02 format?

Found very interesting solution: https://github.com/drpioneer/MikrotikBackup
 
User avatar
Amm0
Forum Guru
Forum Guru
Posts: 4262
Joined: Sun May 01, 2016 7:12 pm
Location: California
Contact:

Re: Dude v6 - Backup locally

Sun Nov 03, 2024 12:07 am

Here is quick hack to adapt the script for newer date format using in V7. I cannot vouch for the restore part, but this should work to keep same format as previous version. Basically the "Get date and time" part is replaced from above:
{

### Backup Dude locally ###

# Set root path for backup

:local localbackuppath "disk1"

# Define variables to use for file generation

:local dudeconffilename "Dude_configuration_backup"
:local dudedbfilename "Dude_db_backup"
:local dudeconffileext "rsc"
:local dudedbfileext "db"

# Get date and time

:local getnow do={
        :local d [/system/clock/get date]; 
        :local t [/system/clock/get time]; 
        :return "$[:pick $d 0 4]$[:pick $d 5 7]$[:pick $d 8 10]-$[:pick $t 0 2]$[:pick $t 3 5]"
}
:local now [$getnow]

# Make Dude backup

:log warn message="Dude backup locally started";

/dude export file="$localbackuppath/$dudeconffilename_$now.$dudeconffileext"
/dude export-db backup-file="$localbackuppath/$dudedbfilename_$now.$dudedbfileext"

:log warn message="Dude backup locally finished"

}

Who is online

Users browsing this forum: No registered users and 5 guests