How to Automate Backup of PFsense Configuration Using CRON

  • 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 "" 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"

    5-  Add a cron Job from PFsense Menu "Services" > CRON
    mine is as follows:
    0 1 * * * root /backup/ >>/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.

  • @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?

Log in to reply