SOLVED Account Restore Failed: Cannot cleanup top level directory

Sadaqat

Registered
Apr 28, 2017
2
1
3
Bahrain
cPanel Access Level
Root Administrator
My VPS crashed so setup a new VPS and moving *.tar.gz cPanel accounts from backup and restoring them through Full Backup restore function of WHM, however running into captioned error for every account transferred.
Failed: Account Restore Failed: “clean: Cannot cleanup top level directory: “/cpanelpkgrestore.TMP.work.3x9vXyS3 ”. at /usr/local/cpanel/Whostmgr/Transfers/ArchiveManager.pm line 668. ”
Took the liberty to check the line 668 in ArchieveManager.pm and it corresponds to the following codes string:
Code:
sub cleanup {
    my ($self) = @_;

    if ( $self->{'_temp_extract_dir'} && -e $self->{'_temp_extract_dir'} ) {

        # Ensure we never clean /XXXX
        # These are various safety checks to avoid blowing away
        # any directories that should never be cleaned up
        my $target_with_trailing_slash = $self->{'_temp_extract_dir'};
        $target_with_trailing_slash =~ s{/+$}{};
        if ( ( $target_with_trailing_slash =~ tr{/}{} ) <= 1 ) {
            die "clean: Cannot cleanup top level directory: “$self->{'_temp_extract_dir'} ”.";
        }

        my $run = Cpanel::SafeRun::Object->new(
            program => '/bin/rm',
            args    => [ '--recursive', '--force', '--', $self->{'_temp_extract_dir'} ],
        );

        warn $run->stderr() . $run->autopsy() if $run->CHILD_ERROR();
Can you please tell me what is the solution to this? It seems there some "/" in the restore files thats causing the issue here, but how can change/resolve/bypass that and get the restore to complete?

A quick look at the files reveals that the files have been moved into a temp folder in root however the cpanel account has been created and its mapping the file manager to its respective files - But its not sitting where it should be ... under /home directory. Furthermore the associated domain is not fully functional, while home page links, sub domains dont.
 

cPanelMichael

Administrator
Staff member
Apr 11, 2011
47,913
2,202
363
Hello,

It's possible the permissions on your "/" directory are not allowing the restoration process the ability to complete. Could you try moving the backup archives to the /home directory before starting the restoration process? Let us know if that helps.

Thank you.
 
  • Like
Reactions: Sadaqat

cPanelMichael

Administrator
Staff member
Apr 11, 2011
47,913
2,202
363
Hello,

I'm happy to see that helped. Thank you for updating us with the outcome.