Community discussions

MikroTik App
 
User avatar
Taverius
just joined
Topic Author
Posts: 2
Joined: Wed Jan 24, 2024 8:24 pm

fetch-based backup script (wip)

Tue Feb 13, 2024 11:57 pm

Something I've been working on: https://github.com/Taverius/ros-fetch-backup

I wanted a script to backup as much as possible to my sftp host, and couldn't find anything that did quite what I needed.

So I started with viewtopic.php?t=159432 and viewtopic.php?p=858564#p858564, then got massive scope-creep, because weekend.

Aim is to have a script that can backup as much as reasonably possible via the various '/tool fetch upload=yes' modes.

Currently the option list is as such:
# Server FQDN or IP
:local remoteserver "";
# Server Account Username
:local username "";
# Server Account Password
:local password "";
# Server Path, leave blank to push to root. Path must exist
:local remotepath "";
# Include date in local file names. Leave false to overwrite single files
:local datelocal false;
# Remove local file after uploading
:local removelocal true;
# Binary Backup
:local dobinbackup true;
# Encrypt Backup
:local backupencrypt false;
# Backup Password
:local backuppassword "";
# Sensitive information in Export
:local exportsensitive true;
# General Export
:local dogexport true;
# User Export
:local douexport true;
# License Export (not for CHR, will silently skip)
:local dolicense true;
# SSH Keys
:local dosshkeys false;
# Certificate Export
:local docertificates true;
# Certificate Password
:local certpassword "";
# User-Manager Export
:local dousermanager false;
# The Dude Export
:local dothedude false;
# User Files to export, comma-separated string or array of strings
# User Files are not removed on backup
# Any directory paths will be removed (/ -> _) on remote file
# Nonpresent files are silently skipped
:local userfilelist "autosupout.rif,autosupout.old.rif";

Current state, I'd love some help, either here or on github:

  • Its hardcoded to SFTP because that's what I could easily test here.
    There's only 1 call to 'fetch' which loops over a file list array, so its easy to generalize, I just don't know which of the (many) options people are actually using for the other modes.
  • From cribbing @rextended's export calls it should support V6, The Dude and User-Manager, but I don't use those myself, so they need testing.
  • I'm on CHR so I can't test license key export.
  • SSH-Key export doesn't actually complete until it can echo the system-wide warning about having exported said keys, so if those change frequently (???) they will be scheduler interval out of date to the rest of the backups. Wonder if that's possible to fix.
  • I'd like to implement script-by-script export to make it easy to import single scripts from backups, haven't looked into how to do that yet.

Who is online

Users browsing this forum: vanikcz and 3 guests