• Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Search
  • Register
  • Login
Netgate Discussion Forum
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Search
  • Register
  • Login

How to Automate Backup of PFsense Configuration Using CRON

Scheduled Pinned Locked Moved Development
2 Posts 2 Posters 2.2k Views
Loading More Posts
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M
    mohamednasr
    last edited by Mar 29, 2018, 3:07 PM

    This is a tutorial on how to automate backups of PFsense configuration Using CRON.
    The Steps below have been tested more than 3 times and are working fine:

    1- Install CRON using PFsense Package Manager ( Mine is version 0.3.7_2)

    2- Create a named "backup" on pfsense root folder. I used WinSCP Software to access the root directory on pfsense but you can always use SSH. And keep in mind that you have to allow SSH access on PFsense from System > Advanced > Admin Access > Secure Shell

    3- create a file named "backup_firewall_config.sh" and don't forget to give on both the backup folder and the script.
    This is the script that will be used to backup pfsense configuration.

    4- The body of my script is as follows:

    set -x
    mydate=date +"%Y%m%d%H%M%S"
    BACKUPDEST="/backup/config-pfmaster.local-$mydate.xml"
    scp $REMOTECONFIG $BACKUPDEST

    –-------------------
    5-  Add a cron Job from PFsense Menu "Services" > CRON
    mine is as follows:
    0 1 * * * root /backup/backup_firewall_config.sh >>/backup/result.txt 2>&1

    This means that it will run at the first hour of every day

    I hope this helps someone out.
    I have an update for this script that can upload your configuration to a remote ftp site In case someone wanted to ask for it.

    F 1 Reply Last reply Aug 24, 2018, 8:23 AM Reply Quote 0
    • F
      FearNaBoinne @mohamednasr
      last edited by Aug 24, 2018, 8:23 AM

      @mohamednasr I am 100% positive that things are missing in this script, and just to test it I followed the steps, and it indeed did NOT work AT ALL...

      Perhaps you can revisit this and verify what parts are missing? I can identify at least missing back-quotes (`) around the date section and the setting of $REMOTECONFIG, but somewhere, somehow the backup itself also need to be made, I think?

      1 Reply Last reply Reply Quote 0
      • First post
        Last post
      Copyright 2025 Rubicon Communications LLC (Netgate). All rights reserved.
        [[user:consent.lead]]
        [[user:consent.not_received]]