Community discussions

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

Dude v6 - Backup to FTP

Tue Nov 07, 2017 11:54 pm

Dude v6 - Backup to FTP

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-to-ftp
Policy: ftp, read, write, test
Source:
#
# Backup Dude to FTP
#
# Define variables
:local ftphost "<ftp server host>"
:local ftpuser "<ftp user>"
:local ftppassword "<ftp password>"
:local ftppath "/"
: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 locally
#
: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";
#
# Copy Dude backup to FTP
#
:log warn message="Dude backup to FTP started";
/tool fetch address="$ftphost" src-path="$localbackuppath/$dudeconffilename_$now.$dudeconffileext" user="$ftpuser" mode=ftp password="$ftppassword" dst-path="$ftppath/$dudeconffilename_$now.$dudeconffileext" upload=yes
/tool fetch address="$ftphost" src-path="$localbackuppath/$dudedbfilename_$now.$dudedbfileext" user="$ftpuser" mode=ftp password="$ftppassword" dst-path="$ftppath/$dudedbfilename_$now.$dudedbfileext" upload=yes
:log warn message="Dude backup to FTP finished";
#
# Remove locally created files
#
:log warn message="Removing locally created backups started";
file remove "$localbackuppath/$dudeconffilename_$now.$dudeconffileext"
file remove "$localbackuppath/$dudedbfilename_$now.$dudedbfileext"
:log warn message="Removing locally created backups finished";
#
}
Dude-v6-Backup-to-FTP-01-Script.png

2. Create a schedule.
System --> Scheduler:
Name: backup-dude-to-ftp
Start Day: Nov/07/2017
Start Time: 02:00:00
Interval: 1d 00:00:00
Policy: ftp, read, write, test
On Event: dude-backup-to-ftp
Dude-v6-Backup-to-FTP-02-Schedule.png

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

Used materials
1. Dude v6 - Backup locally
2. Backup to External FTP Useful script
3. Automated RouterOS Backup to FTP

Related solutions
1. Dude v6 - Backup locally
You do not have the required permissions to view the files attached to this post.

Who is online

Users browsing this forum: No registered users and 51 guests