Current File : //scripts/remote_log_transfer
#!/usr/local/cpanel/3rdparty/bin/perl
# cpanel - scripts/remote_log_transfer             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::remote_log_transfer;

=head1 NAME

This script is used to copy all the main system logs from a server to a backup destination
configured in WHM.
For verbose help and examples, call this script with the --morehelp argument.

=cut

use strict;
use warnings;

use Cpanel::Logger        ();
use Cpanel::Config::Users ();

use parent qw( Cpanel::HelpfulScript );

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

use constant _OPTIONS => qw( action=s destid=s local_dir=s remote_dir=s keep debug morehelp );

__PACKAGE__->new(@ARGV)->run() unless caller();

################################################################################
# Much of this is a modification of scripts/cpbackup_transport_file
################################################################################

sub run {
    my ($self) = @_;

    if ( $self->getopt('morehelp') ) {
        show_usage();
        return;
    }

    $self->ensure_root();

    my @transport_ids = split( /,/, $self->getopt('destid') ) if defined( $self->getopt('destid') );
    my $command       = $self->getopt('action');
    my $keep_local    = $self->getopt('keep')       || 0;
    my $local_dir     = $self->getopt('local_dir')  || '/backup/';
    my $remote_dir    = $self->getopt('remote_dir') || 'log_backups';

    if ( !defined $command || !$command ) {
        show_usage();
        return;
    }
    if ( $command eq 'list' ) {
        my $all_files_and_directories_ar = get_all_log_paths();
        foreach my $path ( @{$all_files_and_directories_ar} ) {
            print "$path\n";
        }
    }
    elsif ( $command eq 'transfer' ) {

        $Cpanel::Debug::level = 9999 if ( $self->getopt('debug') );

        if ( !@transport_ids ) {
            print STDERR "\n!!!!! Missing argument “--destid=\$destination_id”\n\n";
            show_usage();
            return;
        }

        # Validate the transport_id(s)
        require Cpanel::Backup::Transport;
        require Cpanel::Backup::Utility;

        my $transports             = Cpanel::Backup::Transport->new();
        my $transport_configs      = $transports->get_enabled_destinations();
        my $transport_config_cnt   = @transport_ids;
        my $one_transport_was_good = 0;
        foreach my $transport_id (@transport_ids) {
            my $matching_cfg = $transport_configs->{$transport_id};
            if ( !$matching_cfg ) {
                print "\nNo backup transports exist or are enabled that match the supplied transport “$transport_id” , skipping..\n";
            }
            else {
                $one_transport_was_good++;
            }
        }
        if ( !$one_transport_was_good ) {
            show_usage();
            return;
        }

        my $log_tarball_path = $self->get_log_backup_path($local_dir);

        print "Creating log backup file $log_tarball_path\n";

        require Cpanel::Backup::Config;
        my %conf    = %{ Cpanel::Backup::Config::load() };
        my $utility = Cpanel::Backup::Utility->new( \%conf );

        my $all_log_paths_ar = get_all_log_paths();

        # Create this file without world-readable permissions
        my $orig_umask = umask(0077);

        # We create a bzip2'd tarball to maximize space savings of mostly text log files
        if ( $utility->cpusystem( 'tar', 'cfpj', $log_tarball_path, @{$all_log_paths_ar} ) == 0 ) {
            chmod( 0600, $log_tarball_path );
        }
        else {
            print STDERR "Failed to create $log_tarball_path : $!\n";
            return;
        }
        umask($orig_umask);

        # keep_local has to be overridden here until the last transport, otherwise it will delete the log backup file after the first transport
        # is done.
        my $transport_cnt     = @transport_ids;
        my $current_transport = 0;
        my $final_keeplocal   = $keep_local;

        foreach my $transport_id (@transport_ids) {
            $current_transport++;
            print "Attempting transport of '$log_tarball_path' using transport ID '$transport_id''.\n";

            # Note, the 'Cpanel::Backup::Queue::transport_backup' package/namespace is also defined by this package, so thus it is imported.
            require Cpanel::Backup::Queue;    # PPI USE OK -- Cpanel::Backup::Queue::transport_backup is defined there
            require File::Basename;

            # Even if keep local is false, but we have more transports, toggle it to true
            if ( $current_transport < $transport_cnt ) {
                $keep_local = 1;
            }
            else {
                $keep_local = $final_keeplocal;
            }

            my $args = {
                local_path  => $log_tarball_path,
                remote_path => $remote_dir . '/' . File::Basename::basename($log_tarball_path),
                local_files => $log_tarball_path,
                keep_local  => $keep_local,                                                       # This has no affect here, but we pass it nonetheless and action the logic a little further down
                session_id  => 'LOG_TRANSFER',
                type        => 'compressed',
                cmd         => 'log_transfer',
                transport   => $transport_id,
            };

            my $logger = Cpanel::Logger->new( { 'use_no_files' => 1 } );
            Cpanel::Backup::Queue::transport_backup->new()->process_task( $args, $logger );    # PPI NO PARSE -- See comment below
                                                                                               # The import of Cpanel::Backup::Queue above via require causes the
                                                                                               # namespace in question here to exist, as it is the kind of package
                                                                                               # which defines multiple packages in one file, as perl allows you to
                                                                                               # do. As this is the "common" design of TaskProcessor modules,
                                                                                               # this is not only expected but appropriate.
        }
        unlink $log_tarball_path if !$keep_local;

    }
    else {
        show_usage();
        return;
    }

    return;
}

################################################################################
# how thing do ?
sub show_usage {
    my $log_file_paths_ar = get_all_log_paths();

    print <<EOU;
    Usage:
        $0 --action=<cmd> <args>
        
        Commands:
          list              - Lists all log paths that will be transferred
          transfer          - Transfer logs to remote server
                              Arguments:
                                 --destid=<DestinationID>
                                        The <DestinationID> can be found in WHM on the Backup Configuration -> Additional Destinations page.
                                        The argument here can support multiple destinations, comma delimited, i.e. --destid=OQosRCmRnTNcLcCojd7C0vhC,TAMdl6LZCxQELuUAVO20SjQm
                                        will upload the log backup to both OQosRCmRnTNcLcCojd7C0vhC and TAMdl6LZCxQELuUAVO20SjQm destinations
                                 --local_dir=/backup
                                        The local directory where the compress log files tarball will be stored before transfering to the remote destinations.
                                        Note that this assumes the local directory given is already mounted.
                                        Defaults to “/backup/”
                                 --remote_dir=remote_path/
                                        The path used to store the log file backup on the remote server, relative or absolute based on transfer destination requirements
                                        Defaults to “log_backups”
                                 --debug
                                        Show verbose debug output
                                 --keep
                                        Keep the local log file backup after transfer to the remote destination(s).
          
    Example usages:
    
        # List all log file locations. Additional custom paths can be added to /var/cpanel/config/extra_remote_transfer_paths.txt
        $0 --action=list
        
        # Transfer all logs to the remote backup destination whose ID is TAMdl6LZCxQELuUAVO20SjQm
        $0 --action=transfer --destid=TAMdl6LZCxQELuUAVO20SjQm
        
        # Same as above, but store the logs in the remote directory “backups/logs/Atlanta/” rather than “log_backups/” , while also keeping the local backup in /mnt/backup2/
        $0 --action=transfer --destid=TAMdl6LZCxQELuUAVO20SjQm --remote_dir=backups/logs/Atlanta/ --local_dir=/mnt/backups2/ --keep
        
        
    Log files:
        Custom file paths can be configured by adding them to /var/cpanel/config/extra_remote_transfer_paths.txt , one line for each path.
        Be careful if adding paths here as no validation is done.
        
EOU
    print "\t\tCurrently configured paths:\n\n";
    foreach my $path ( @{$log_file_paths_ar} ) {
        print "\t\t-\t$path\n";
    }
    print "\n";
    return;
}

################################################################################
# We might want to add this to Cpanel/Backup/SystemResources.pm at some point, but this script also should be as independant as possible

sub get_all_log_paths {
    my @paths = (
        "/var/log/",
        "/usr/local/cpanel/logs/",
        "/var/cpanel/logs/",
        "/var/cpanel/updatelogs/",
    );

    require Cpanel::PwCache;
    foreach my $user ( Cpanel::Config::Users::getcpusers() ) {
        my $homedir = Cpanel::PwCache::gethomedir($user);
        push @paths, "$homedir/logs/";
    }

    if ( open( my $custom_extra_fh, '<', '/var/cpanel/config/extra_remote_transfer_paths.txt' ) ) {
        while (<$custom_extra_fh>) {
            chomp;
            my $c_path = $_;
            if ( $c_path !~ m/^\// ) {
                print STDERR "Custom path “$c_path” must be absolute ( start with / ), ignoring\n";
            }
            else {
                if ( -f $c_path || -d _ ) {
                    push( @paths, $c_path );
                }
                else {
                    print STDERR "Custom path “$c_path” is not a file or directory, ignoring.\n";
                }
            }
        }
        close($custom_extra_fh);
    }
    return \@paths;
}

################################################################################
# broken out for easier testing
sub get_log_backup_path {
    my ( $self, $local_dir ) = @_;

    # Create log file backup from all paths in get_all_log_paths() with a base directory
    require Cpanel::Hostname;
    my $hostname = Cpanel::Hostname::gethostname();

    my ( $sec, $min, $hour, $mday, $mon, $year, undef, undef, undef ) = localtime();
    my $formatted_date = sprintf( "%04d-%02d-%02d_%02d-%02d-%02d", $year + 1900, $mon, $mday, $hour, $min, $sec );

    my $log_tarball_path = $local_dir . '/log_backup_' . $hostname . '_' . $formatted_date . '.tar.bz2';
    return $local_dir . '/log_backup_' . $hostname . '_' . $formatted_date . '.tar.bz2';
}
################################################################################

1;
Gay Pornography Blog Explicit images and videos offering the newest homosexual porno moments & pornography stars

Gay Pornography Blog Explicit images and videos offering the newest homosexual porno moments & pornography stars

Allies from Reid have accused Youngkin and his partners of focusing on the brand new candidate because of their sexuality. Reid are Virginia’s basic publicly homosexual statewide nominee. Reid has declined the newest account are their and you can would not action away — leaving group loyal scrambling in order to unite regarding the half a year from the state’s bellwether 2025 from-year election. Okay, very I’m pretty sure all of these movies are novice.

Anna beggion sex videos: Implant it video clips on the page using this code

Research and acquire all anna beggion sex videos of the gender information of the greatest homosexual pornography celebrities on the adult industry. Find in which gay porn video clips he’s played thanks to these IMDB gay adult film database and you may homosexual p… Check out 100 percent free Hd gay rape porn fantasy video to the very popular homosexual pornography hoses worldwide.

BongHunk – Day sex with my date

This site has been in existence for only nine weeks, or at least it seems like one to, and they curently have a significant-measurements of video clips collection. Their upload plan are both insane, otherwise they just ensured that people features lots of posts to watch right away. In either case, you will not use up all your what to observe anytime soon, so you have absolutely nothing to consider. Unlike pushing you to definitely read the latest content, they just state new stuff is coming every day, that is good enough for me personally. Although not, the greater amount of bottom line is whether or not these moments look nice otherwise not, thus why don’t we see. Scott DeMarco and you will Filou Fitt have created an intimate atmosphere which have delicate lights as they hug and you can strip down one another for the sleep.

Check out and you can download full-length 720p/1080p/4K High definition vintage homosexual porn video clips in the most famous homosexual porn studios. Load private classic gay adult Cds that have old-fashioned male porn superstars from the 60s, 70s… Observe free High definition homosexual bareback porn movies on the most widely used homosexual intercourse tubes worldwide. Discover explicit gay porno video out of sensuous men and men pornography superstars having rectal intercourse without condom. Check out and you can install 720p/1080p/4K homosexual twink porn movies in the most well-known homosexual porn studios. Weight private full-duration homosexual gender movies from adorable slim guys, sexy 18-year-dated males and you will younger male po…

Best Yaoi Manga Web sites

anna beggion sex videos

“People on line can be unlock profile with the exact same or equivalent brands while the someone else.

Or maybe you want gay shag movies having shy males and masculine alphas? Our curator ensures you have made an informed mature homosexual banging vids. Are you searching for the most popular gay pornography videos?

Gay Porn POV: Alex Kof Takes Angelo Sin’s Huge Penis

Stream exclusive complete-size gay intercourse video with nasty men porn stars pissing, pooping, farting and you may eat… View and you can download 720p/1080p/4K homosexual bareback porno video on the most famous gay pornography studios. Load private full-length homosexual sex videos away from gorgeous people screwing both anally with no condom!

We’ve got obtained the best of the best all-in-one place in order to take pleasure in high quality pornography videos, amateur homosexual intercourse movies, passionate photos and you can gifs and so much more. Do not hesitate to search all of our larger, heavy collection of movies and select away from a variety of video classes and. A robust look setting places the advantage on your own give when you are helpful sorting and you may filter systems enables you to easily view the current or most popular homosexual Adult inside a pinch.


Publicado

en

por

Etiquetas: