| Post Reply | RetroFed Forums Forum Index » Selfhosted |
| Author | Message | ||
|---|---|---|---|
|
MuttMutt lemmy.world MuttMutt@lemmy.world Joined: 2023-06-18 |
So here is the deal. OpnSense is based on FreeBSD (as the users know but others may not understand) and utilizes ZFS Snapshots which are an amazing way to go back to a previous state when something breaks after an update. However for some reason the cron section has been changed so you can not add any random cron job and can only select from predefined options. This means we have to work from the CLI to add jobs, but even worse after an update the cron jobs are removed.... which becomes self defeating. I think I have a decent solution that will work to not only persist the backup script that will automatically create and remove snapshots but also recreate the cron jobs automatically. Ideally there would be some sort of addon where we could adjust things but this is the best I can do for now and want to share with everyone. Here is the script, place it at: /usr/local/etc/rc.syshook.d/start/99-snapshot-addon.sh
This will check for and if missing create a script at /usr/local/opnsense/scripts/auto_be_retention.sh and it will check for and if missing create two cron jobs. The script located at /usr/local/opnsense/scripts/auto_be_retention.sh will create a snapshot with a timestamp named similar to: auto_monthly_20261001_033000 It will also look the count of previous snapshots (6 for weekly and 4 for monthly which can be adjusted if you choose) and delete the oldest one. Weekly snapshots will happen every Sunday at 3:00 AM and monthly snapshots will happen on the 1st of the month at 3:30 AM. Why do we need this? We don't "need" this but the advantage is that if you can have automatic updates (which are an option that is available in the cron section) it's probably better to have a snapshot that can easily be rolled back to in the case of something acting up automatically created as well. The other option is try and undo the issue or take a config backup and reinstall then use that to get everything up and running again. Rolling back a snapshot takes a few minutes and gets everything back up and running until a solution for the issue/s are available. I ran the script and I am not seeing anything in the Settings > cron section!! You won't... that is part of the deal with how OpnSense has decided to handle things. You will need to look in: /etc/crontab This is because of how OpnSense is using menu drive cron selections, since the selections are not available it seems to not want to create or show them. I have done some testing and removed the files and jobs and also had them recreated. At the next update we will see if everything sticks around or if it is removed. Please remember that the script above is given without warranty or guarantee, use it at your own risk. I am not responsible if this script causes things not limited to but including data loss, testicular/breast shrinkage/growth, rude children, nagging wives/girlfriends/husbands/partners, alien visitation, global warming, or thermonuclear war. ID10T errors are also your own responsibility... you should not be running things you find on the internet without understanding how they work. |
||
| 36 Original | |||
|
zo0 programming.dev zo0@programming.dev Joined: 2024-12-07 |
Have you tried rrstoring to a previous snapshot after a borked update? |
||
| 2 | |||
|
non_burglar lemmy.world non_burglar@lemmy.world Joined: 2023-06-16 |
|
||
| 3 | |||
|
MuttMutt lemmy.world MuttMutt@lemmy.world Joined: 2023-06-18 |
Have you tried rrstoring to a previous snapshot after a borked update?
On OpnSense no. I previously did not have snapshots created. I have on FreeNAS when I had a setting issue that came up. Fundamentally it should be no different. I have had to reinstall OpnSense before and would rather not go through that again if at all possible. |
||
| 1 | |||
| Post Reply | Page 1 |