Edit File: backups_list_user_files
#!/usr/local/cpanel/3rdparty/bin/perl # cpanel - backups_list_user_files Copyright 2017 cPanel, Inc. # All rights Reserved. # copyright@cpanel.net http://cpanel.net # This code is subject to the cpanel license. Unauthorized copying is prohibited package scripts::backups_list_user_files; use strict; use warnings; use Cpanel::Backup::StreamFileList (); use Getopt::Long (); use Text::CSV (); use MIME::Base64 (); sub _help { my ($msg) = @_; print qq{$msg Usage: $0 --user=user [--regexp=regexp] [--skipcompressed] user - is the name of the user files to list regexp - is an optional regex to refine your file list skipcompressed - skip over any compressed backups }; exit 0; } sub _invalid_parms { _help(); die "Invalid Command Line Parameters\n"; } our $user; our $regexp; our $skipcompressed; our $csv; sub _output { my ($line) = @_; print $line . "\n"; return; } sub input_data { my ($line) = @_; $csv //= Text::CSV->new(); $csv->parse($line); my @columns = $csv->fields(); $columns[2] = MIME::Base64::decode_base64( $columns[2] ); $csv->combine(@columns); $line = $csv->string(); if ($regexp) { my ( $size, $date, $full, $fname ) = @columns; if ( $full =~ m/$regexp/ ) { _output($line); } return; } _output($line); return; } sub script { my (@args) = @_; my $opts = Getopt::Long::GetOptionsFromArray( \@args, 'user=s' => \$user, 'regexp=s' => \$regexp, 'skipcompressed' => \$skipcompressed, ) or _invalid_parms(); _help("no user provided") if !$user; Cpanel::Backup::StreamFileList::stream_files( $user, \&input_data, $skipcompressed, 1 ); return 1; } exit( script(@ARGV) ? 0 : 1 ) unless caller();