snipe-it icon indicating copy to clipboard operation
snipe-it copied to clipboard

Backups Frequency Change

Open LSNIGHTSHOT opened this issue 4 years ago • 10 comments

Debug mode

Describe the bug

My instance is running a backup every hour and is not deleting any old backups. Looking for a way to edit this.

Thanks.

Reproduction steps

  1. Go to C:\inetpub\wwwroot\snipeit\storage\app\backups
  2. This is where all the backups are located and stored. Which is where I found hourly backups for the last 2 years. (C drive was filling up.)

Expected behavior

Create backups daily instead of hourly. Delete backups older than "X" time.

Screenshots

No response

Snipe-IT Version

5.3.10

Operating System

Windows Server 2022

Web Server

IIS

PHP Version

7.4.19

Operating System

Windows 11

Browser

Edge

Version

98.0.1108.50

Device

No response

Operating System

No response

Browser

No response

Version

No response

Error messages

No response

Additional context

I have read through the documentation here however it doesn't appear to work on Windows.

https://snipe-it.readme.io/docs/configuring-alerts-backups

LSNIGHTSHOT avatar Feb 14 '22 18:02 LSNIGHTSHOT

👋 Thanks for opening your first issue here! If you're reporting a 🐞 bug, please make sure you include steps to reproduce it. We get a lot of issues on this repo, so please be patient and we will get back to you as soon as we can.

welcome[bot] avatar Feb 14 '22 18:02 welcome[bot]

That really depends on what your Scheduled Tasks look like. (Also you should upgrade your version of Snipe-IT.)

The rules currently in place if you're just letting Snipe-IT's scheduler handle things is:

'default_strategy' => [

            /*
             * The number of days for which backups must be kept.
             */
            'keep_all_backups_for_days' => 7,

            /*
             * The number of days for which daily backups must be kept.
             */
            'keep_daily_backups_for_days' => 16,

            /*
             * The number of weeks for which one weekly backup must be kept.
             */
            'keep_weekly_backups_for_weeks' => 8,

            /*
             * The number of months for which one monthly backup must be kept.
             */
            'keep_monthly_backups_for_months' => 4,

            /*
             * The number of years for which one yearly backup must be kept.
             */
            'keep_yearly_backups_for_years' => 2,

            /*
             * After cleaning up the backups remove the oldest backup until
             * this amount of megabytes has been reached.
             */
            'delete_oldest_backups_when_using_more_megabytes_than' => 5000,
        ],

But if you've overridden any of that by invoking the backup artisan command directly via Scheduled Tasks, we cannot seek to that part.

snipe avatar Feb 14 '22 18:02 snipe

Isn't 5.3.10 the most recent? image

I have no scheduled tasks in place pertaining to backups. Is the Windows Task scheduler the preferred way to invoke the command or do I edit the file you referenced?

LSNIGHTSHOT avatar Feb 14 '22 18:02 LSNIGHTSHOT

My apologies, I read that as 5.3.1. Not enough coffee yet this morning :)

You should not edit the file I referenced, since that's going to make keeping your Snipe-IT up to date more difficult. What Snipe-IT scheduled tasks do you have set up currently?

snipe avatar Feb 14 '22 18:02 snipe

But also, that default schedule should be pretty reasonable - its not saving every backup for 2 years, just a yearly backup for 2 years - and the garbage collection is built in based on space, so that should be something that works for most use cases.

snipe avatar Feb 14 '22 18:02 snipe

Ah no worries!

I think you may be on to something. So I have two scheduled tasks. One that syncs LDAP every hour and one that checks for upgrades every hour.

Does the php upgrade.php command initiate a backup?

If so that is where my problem is.

LSNIGHTSHOT avatar Feb 14 '22 18:02 LSNIGHTSHOT

Huh, yeah it does, even if there's nothing to upgrade to as I look at it.

uberbrady avatar Feb 14 '22 18:02 uberbrady

Indeed it does. We unfortunately have to assume that not everyone is diligent about backing up, so before we apply updates, we try to backup the system.

Maybe change that upgrade.php task to daily or weekly?

You didn't mention whether or not you have the "normal" Snipe-IT schedule-handley-thingie set up as a scheduled task (the php artisan schedule:run bit, which wraps all of the normal stuff into one command.) If you do have that running anywhere, that would also back you up twice, since the scheduled backup script has no knowledge of outside generated backups.

snipe avatar Feb 14 '22 18:02 snipe

@snipe Yup I just changed it to daily at 12:00 AM.

I do not have the php artisan schedule:run in any task scheduler.

Thanks for your help!

LSNIGHTSHOT avatar Feb 14 '22 18:02 LSNIGHTSHOT

Happy to help :)

snipe avatar Feb 14 '22 18:02 snipe