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

Cron job for saving RRD graph data on embedded installs

Scheduled Pinned Locked Moved webGUI
4 Posts 2 Posters 4.9k 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.
  • X
    xak
    last edited by Jun 19, 2012, 11:31 PM

    Related topic: http://forum.pfsense.org/index.php?topic=10629

    Summary: pfSense embedded installs only save RRD graph data on shutdown or reboot (via /etc/rc.shutdown and /etc/rc.reboot). If it suffers a non-graceful reboot, all RRD data since the last graceful shutdown or reboot will be lost. The solution is to add a cron job which saves this data to the /cf partition, making it persistent. I recently ran into this issue on my embedded pfSense deployment, and lost 6 months of logs. So, I found the above thread discussing the solution, however I had to update a couple things to work with version 2.0. I figured I'd share it here in the hopes it will help someone else.

    Solution: You'll need to save your pfSense config to an XML file, add the following entry to the <cron>section (make sure to preserve the XML file format), and re-upload it to your system. It will reboot automatically and apply the changes. You can then log in via shell or console and look in /etc/crontab to make sure the entry got added, or check your System Log for log entries indicating that it has run on schedule.

    Here is my config.xml cron entry:

     <minute>0</minute>
            <hour>0</hour>
            <mday>*</mday>
            <month>*</month>
            <wday>*</wday>
            <who>root</who>
            <command></command> 
    
    

    Which results in this entry in /etc/crontab:

    0	0	*	*	*	root	echo "RRD backup starting" |logger; /usr/bin/nice -n20 /etc/rc.backup_rrd.sh && echo "RRD backup complete" |logger || echo "RRD backup ERROR" |logger
    

    A few items of note:

    • Runs at midnight every day; change to suit your needs.

    • Calls /etc/rc.backup_rrd.sh which is the script which handles mounting /cf as read-write or read-only (previously the commands were placed directly in cron, presumably this script is new for 2.0).

    • The <command></command>value is encapsulated with CDATA, which is necessary to preserve the non XML friendly characters like ampersands in the command string.

    • Will log the start and subsequent success or failure of the backup script in the pfSense system log.

    • This does increase filesystem writes (although not by very much), so be aware of this depending on the flash storage you are using.

    Hope this helps someone!</cron>

    PC Engines APU1D 4GB
    SanDisk mSATA SSD P4 16GB
    2.4.0-RELEASE (amd64)
    TL-SG1024DE + UAP-AC-PRO
    TWC 200/20 Mbit

    1 Reply Last reply Reply Quote 0
    • J
      jimp Rebel Alliance Developer Netgate
      last edited by Jun 24, 2012, 5:53 PM

      On Diag > NanoBSD, you can already set an RRD backup or DHCP leases backup frequency, which automatically adds a cron job for you.

      Remember: Upvote with the 👍 button for any user/post you find to be helpful, informative, or deserving of recognition!

      Need help fast? Netgate Global Support!

      Do not Chat/PM for help!

      1 Reply Last reply Reply Quote 0
      • X
        xak
        last edited by Jun 28, 2012, 5:07 AM

        Wow, I sure went about it the hard way!  :o

        Thanks for your reply. When was that feature added?

        PC Engines APU1D 4GB
        SanDisk mSATA SSD P4 16GB
        2.4.0-RELEASE (amd64)
        TL-SG1024DE + UAP-AC-PRO
        TWC 200/20 Mbit

        1 Reply Last reply Reply Quote 0
        • J
          jimp Rebel Alliance Developer Netgate
          last edited by Jun 28, 2012, 5:11 AM

          August 9, 2010. :-)

          Remember: Upvote with the 👍 button for any user/post you find to be helpful, informative, or deserving of recognition!

          Need help fast? Netgate Global Support!

          Do not Chat/PM for help!

          1 Reply Last reply Reply Quote 0
          4 out of 4
          • First post
            4/4
            Last post
          Copyright 2025 Rubicon Communications LLC (Netgate). All rights reserved.
            This community forum collects and processes your personal information.
            consent.not_received