PFsense Auto Backup powershell script

I’m all about setting it and forgetting it and hopefully this wrapper script helps you do that. I setup this script in 2018 and it’s been performing flawlessly ever since. I know PFsense does it’s own cloud backup but I like to have my own local backup just in case.

Everything is available on github:



  • Logs everything it does
  • Sends pushover alerts on both success and failures (can be toggled on or off)
  • Auto-deletes old backups after ‘X’ amount of days
    • Only auto-deletes if ‘X’ number of backup files exist
  • pfsensebackupv2.ps1 is completely self configuring, prompts and stores your inputs in an .xml file

pfsensebackup.ps1 – configuration

  1. Edit the Powershell script and change the below variables to match your environment:
$backupdir = "" #where your backup files will go (leave a trailing backslash)
$appdir = "" #where the backup app exe lives (leave a trailing backslash)
$username = "" #PFSense Username
$pw = "" #PFSense Password
$pfaddress = "192.168.x.x" #PFSense address
$retention = "-30" #how many days to keep old backup files (Must be negative value, -30 = files older than 30 days)
$fileName = "pfsensebackup" #name of your log file (put into your $backupdir)
$usepush = "y" #use pushover? (y or n)
$pushoverapp = "c:\somepath\pushovercli.exe" #location of the pushovercli
$minbackups = "5" #minimum number of backup files before files are auto-deleted
  1. Create a new scheduled task in Windows with the following:
    • General Tab “Run whether a user is logged in or not” selected -> Action “Start a program” -> Program/Script “Powershell” -> Add Arguments “-f c:\pathtoyourscript\pfsensebackup.ps1”
  2. If you are using Pushover for notifications configure

Log file
Example pushover notification

Leave a Reply