Sebastiaan Dammann

Blogging, coding, 3D printing and reviews

How-to: Implement a daily Edgerouter backup

Configuration of a router is often a task which costs a fair amount of time. Therefore it is often useful to keep several backups of the entire configuration partition. The script below takes a backup of the /config partition of an Ubiquiti Edgerouter and uploads it to a FTP server.

Install the script files in /config/user-data, then register it with the task scheduler:

set system task-scheduler task daily-backup executable path /config/user-data/config-backup
set system task-scheduler task daily-backup interval 1d

Make sure that /config/user-data/config-backup is marked as executable!

chmod +x /config/user-data/config-backup

How it works

The script works as follows:

  1. Tar the /config folder to /tmp.
  2. Upload the archive to an FTP server.
  3. Clean up older uploaded archives from the FTP server.

Because the date command in EdgeOS is too limited to create a date in format YYYY-MM-DD and cannot calculate dates, we use an external helper script in Perl (which is by default installed on EdgeOS) to create a date string.


What are your thoughts?