0
     !687     !#!/usr/local/cpanel/3rdparty/bin/perl

# cpanel - scripts/phpini_tidy                     Copyright 2022 cPanel, L.L.C.
#                                                           All rights reserved.
# copyright@cpanel.net                                         http://cpanel.net
# This code is subject to the cPanel license. Unauthorized copying is prohibited

use Cpanel::Env          ();
use Cpanel::PHPINI::Tidy ();

my $invoked_as_script = !caller();

__PACKAGE__->script(@ARGV) if ($invoked_as_script);

sub script {
    Cpanel::Env::clean_env( 'http_purge' => 1 );

    Cpanel::PHPINI::Tidy::phpini_tidy();

    if ($invoked_as_script) {
        exit(0);
    }

    return 1;
}
     # >    ##!/usr/local/cpanel/3rdparty/bin/perl

# cpanel - scripts/backups_create_metadata         Copyright 2022 cPanel, L.L.C.
#                                                           All rights reserved.
# copyright@cpanel.net                                         http://cpanel.net
# This code is subject to the cPanel license. Unauthorized copying is prohibited

################################################################################

package scripts::backups_create_metadata;

use strict;
use warnings;

use Cpanel::Backup::Config         ();
use Cpanel::Backup::Metadata       ();
use Cpanel::Backup::StreamFileList ();
use Cpanel::Config::LoadCpConf     ();
use Cpanel::ConfigFiles            ();
use Cpanel::FileUtils::Path        ();
use Cpanel::IONice                 ();
use Cpanel::Logger                 ();
use Cpanel::OSSys                  ();
use Cpanel::OSSys::Capabilities    ();
use Cpanel::SafeRun::Simple        ();

use Getopt::Long ();
use File::Glob   ();
use File::Spec   ();

use Try::Tiny;

################################################################################

our $all;
our $backup;
our $user;
our $vacuum;
our $schedule_rebuild;
our $fix_corrupt;

our $logger;

sub _help {
    my ($msg) = @_;

    print qq{$msg

Usage:

--all - Create metadata for all backups in the configured directory.

e.g. $0 --all
This creates metadata for all backups and users.
If metadata exists, it will delete it and create new metadata.
You cannot combine --all with other options.

--vacuum - Defragment the database and release unused space, runs in the background

e.g. $0 --vacuum
This defragments the database and release unused space.
You cannot combine --vacuum with other options.

--backup=monthly/YYYY-MM-DD - Create metadata for all users in the backup directory that you specify.

e.g. $0 --backup=monthly/2017-03-01
This creates metadata for all users in this backup directory.
You can combine this option with the --user option.
e.g. $0 --backup=monthly/2017-03-01 --user=alvin
This creates metadata for this user in this backup directory.

--user=user - Create metadata only for this user.

e.g. $0 --user=alvin
This creates metadata only for this user.
You can combine this option with the --backup=monthly/YYYY-MM-DD option.
e.g. $0 --backup=monthly/2017-03-01 --user=alvin
This creates metadata for this user in this backup directory.

--schedule_rebuild - Rebuild all metadata in the background.

e.g. $0 --schedule_rebuild
This rebuilds all metadata. The script returns to the command line immediately and
continues to rebuild the metadata in a background task.
You can combine this option with the --fix_corrupt option.
e.g. $0 --schedule_rebuild --fix_corrupt
This scans all user metadata and rebuilds corrupt metadata. The script returns to
the command line immediately and continues to rebuild the metadata in a background
task.

--fix_corrupt - Scans all user metadata to identify and rebuild corrupt metadata.
e.g. $0 --fix_corrupt
This scans all user metadata and rebuilds corrupt metadata.
You can combine this option with the --schedule_rebuild option.
e.g. $0 --schedule_rebuild --fix_corrupt
This scans all user metadata and rebuilds corrupt metadata. The script returns to
the command line immediately and continues to rebuild the metadata in a background
task.
};

    exit 0;
}

sub _