stefanpejcic / cPanel-to-OpenPanel

Free OpenPanel module to import cPanel backup in OpenPanel
1 stars 2 forks source link

Migrator couldn't create user and restore backup #20

Open caesarmind opened 5 days ago

caesarmind commented 5 days ago

`root@op1:~# bash cPanel-to-OpenPanel/cp-import.sh --backup-location /root/backup-10.15.2024_16-55-51_gogadigi.tar.gz --plan-name "deluxe" Import started, log file: /var/log/openpanel/admin/imports/backup-10.15.2024_16-55-51_gogadigi.tar_2024-10-17_08-59-55.log

------------------ STARTING CPANEL ACCOUNT IMPORT ------------------

Currently supported features:

emails, nodejs/python apps and postgres are not yet supported!


if you experience any errors with this script, please report to https://github.com/stefanpejcic/cPanel-to-OpenPanel/issues

[2024-10-17 08:59:55] Log file: /var/log/openpanel/admin/imports/backup-10.15.2024_16-55-51_gogadigi.tar_2024-10-17_08-59-55.log [2024-10-17 08:59:55] PID: 1518208 [2024-10-17 08:59:55] Identified full or partial cPanel backup [2024-10-17 08:59:55] There is enough disk space to extract the archive and copy it to the home directory. [2024-10-17 08:59:55] Username: gogadigi [2024-10-17 08:59:55] Username gogadigi is available, starting import.. [2024-10-17 08:59:55] Checking and installing dependencies... [2024-10-17 08:59:55] All required dependencies are already installed. [2024-10-17 08:59:56] Created temporary directory: /tmp/cpanel_import_PFagMZ [2024-10-17 08:59:56] Extracting backup from /root/backup-10.15.2024_16-55-51_gogadigi.tar.gz to /tmp/cpanel_import_PFagMZ [2024-10-17 09:01:17] Backup extracted successfully. [2024-10-17 09:01:18] Extracted backup folder: /tmp/cpanel_import_PFagMZ/backup-10.15.2024_16-55-51_gogadigi/homedir/semele.satesto.live/wp-content/uploads/redux [2024-10-17 09:01:18] Locating important files in the extracted backup [2024-10-17 09:01:19] Backup directories located successfully [2024-10-17 09:01:19] Home directory: /tmp/cpanel_import_PFagMZ/backup-10.15.2024_16-55-51_gogadigi/homedir [2024-10-17 09:01:19] MySQL directory: /tmp/cpanel_import_PFagMZ/backup-10.15.2024_16-55-51_gogadigi/mysql [2024-10-17 09:01:19] MySQL grants: /tmp/cpanel_import_PFagMZ/backup-10.15.2024_16-55-51_gogadigi/mysql.sql [2024-10-17 09:01:19] cPanel configuration: /tmp/cpanel_import_PFagMZ/backup-10.15.2024_16-55-51_gogadigi/cp/gogadigi [2024-10-17 09:01:19] Starting to parse cPanel metadata... [2024-10-17 09:01:19] DEBUG: Attempting to parse metadata from file: /tmp/cpanel_import_PFagMZ/backup-10.15.2024_16-55-51_gogadigi/homedir/semele.satesto.live/wp-content/uploads/redux/cp/gogadigi [2024-10-17 09:01:19] WARNING: cp file /tmp/cpanel_import_PFagMZ/backup-10.15.2024_16-55-51_gogadigi/homedir/semele.satesto.live/wp-content/uploads/redux/cp/gogadigi not found. Using default values. [2024-10-17 09:01:19] cPanel metadata parsed: [2024-10-17 09:01:19] Main Domain: Not found [2024-10-17 09:01:19] Email: Not found [2024-10-17 09:01:19] PHP Version: inherit [2024-10-17 09:01:19] Finished parsing cPanel metadata. du: cannot access '/tmp/cpanel_import_PFagMZ/backup-10.15.2024_16-55-51_gogadigi/homedir/semele.satesto.live/wp-content/uploads/redux/homedir': No such file or directory`

caesarmind commented 2 days ago

Tried to migrate another user, but still no luck.

[2024-10-20 01:38:44] Log file: /var/log/openpanel/admin/imports/backup-10.19.2024_21-24-43_cpaneluser.tar_2024-10-20_01-38-44.log [2024-10-20 01:38:44] PID: 5453 [2024-10-20 01:38:44] Identified full or partial cPanel backup [2024-10-20 01:38:44] There is enough disk space to extract the archive and copy it to the home directory. [2024-10-20 01:38:44] Username: cpanelusernam(I CHANGED IT) [2024-10-20 01:38:44] Username cpanechangername is available, starting import.. [2024-10-20 01:38:44] Checking and installing dependencies... [2024-10-20 01:38:44] All required dependencies are already installed. [2024-10-20 01:38:44] Created temporary directory: /tmp/cpanel_import_CfMzhE [2024-10-20 01:38:44] Extracting backup from /root/backup-10.19.2024_21-24-43_cpanelusername.tar.gz to /tmp/cpanel_import_CfMzhE [2024-10-20 01:38:58] Backup extracted successfully. [2024-10-20 01:38:58] Extracted backup folder: /tmp/cpanel_import_CfMzhE/backup-10.19.2024_21-24-43_cpanelusrname [2024-10-20 01:38:58] Locating important files in the extracted backup [2024-10-20 01:38:58] Backup directories located successfully [2024-10-20 01:38:58] Home directory: /tmp/cpanel_import_CfMzhE/backup-10.19.2024_21-24-43_cpanelusernme/homedir [2024-10-20 01:38:58] MySQL directory: /tmp/cpanel_import_CfMzhE/backup-10.19.2024_21-24-43_cpanelusername/mysql [2024-10-20 01:38:58] MySQL grants: /tmp/cpanel_import_CfMzhE/backup-10.19.2024_21-24-43_cpanelusername/mysql.sql [2024-10-20 01:38:58] cPanel configuration: /tmp/cpanel_import_CfMzhE/backup-10.19.2024_21-24-43_cpanelusername/cp/cpanelusername [2024-10-20 01:38:58] Starting to parse cPanel metadata... [2024-10-20 01:38:58] DEBUG: Attempting to parse metadata from file: /tmp/cpanel_import_CfMzhE/backup-10.19.2024_21-24-43_cpanelusername/cp/cpanelusername [2024-10-20 01:38:58] Additional metadata parsed: [2024-10-20 01:38:58] IP Address: 203.229.111.112 [2024-10-20 01:38:58] Plan: whmcs_BUSINESS [2024-10-20 01:38:58] Max Addon Domains: unlimited [2024-10-20 01:38:58] Max FTP Accounts: unlimited [2024-10-20 01:38:58] Max SQL Databases: unlimited [2024-10-20 01:38:58] Max Email Accounts: unlimited [2024-10-20 01:38:58] Max Subdomains: unlimited [2024-10-20 01:38:58] cPanel metadata parsed: [2024-10-20 01:38:58] Main Domain: domain(hidden).ge [2024-10-20 01:38:58] Email: mail@gmail.com [2024-10-20 01:38:58] PHP Version: 8.0 [2024-10-20 01:38:58] Finished parsing cPanel metadata. [2024-10-20 01:38:58] Restoring files (1.2G) to /home/cpanelusername/ [2024-10-20 01:38:58] Moving main domain files from public_html to domain.ge directory.

stefanpejcic commented 2 days ago

Try to troubleshoot it:

In the first one it says that semele.satesto.live/wp-content/uploads/redux/homedir does not exist

what Is that directory on cpanel? Symlink maybe?

2nd, [2024-10-20 01:38:58] Moving main domain files from public_html to domain.ge directory does it just freeze on this Step? What Is the disk size of that directory? Did you check the process if its running? Strace to see what Is going on

caesarmind commented 1 day ago

Try logging restore_files function.

restore_files() {
    du_needed_for_home=$(du -sh "$real_backup_files_path/homedir" | cut -f1)
    log "Restoring files ($du_needed_for_home) to /home/$cpanel_username/"

    if [ "$DRY_RUN" = true ]; then
        log "DRY RUN: Would restore files to /home/$cpanel_username/"
        return
    fi

    # Log the value of $real_backup_files_path
    log "real_backup_files_path is set to: $real_backup_files_path"

    # Check if /home/$cpanel_username exists, create it if not
    if [ -d "/home/$cpanel_username" ]; then
        log "/home/$cpanel_username exists."
    else
        log "/home/$cpanel_username does not exist. Creating directory."
        if mkdir -p "/home/$cpanel_username"; then
            log "Successfully created /home/$cpanel_username."
        else
            log "ERROR: Failed to create /home/$cpanel_username. Aborting the file move operation."
            return
        fi
    fi

    # Log contents of source directory before moving
    log "Contents of $real_backup_files_path/homedir before moving:"
    ls -lah "$real_backup_files_path/homedir" | tee -a "$log_file"

    log "Attempting to move $real_backup_files_path/homedir to /home/$cpanel_username/"

    # Perform the move and log if it succeeds or fails
    if mv "$real_backup_files_path/homedir" "/home/$cpanel_username"; then
        log "Successfully moved homedir to /home/$cpanel_username."
        # Log contents of the destination directory after the move
        log "Contents of /home/$cpanel_username after moving:"
        ls -lah "/home/$cpanel_username" | tee -a "$log_file"
    else
        log "ERROR: Failed to move homedir to /home/$cpanel_username."
    fi

    # Check for and move public_html
    if [ -d "/home/$cpanel_username/public_html" ]; then
        log "Moving main domain files from public_html to $main_domain directory."
        if mv /home/$cpanel_username/public_html /home/$cpanel_username/$main_domain; then
            log "Successfully moved public_html to $main_domain."
        else
            log "ERROR: Failed to move public_html to $main_domain."
        fi
    else
        log "WARNING: /home/$cpanel_username/public_html does not exist. Skipping the move operation."
    fi

    # Check for and remove symlink www
    if [ -L "/home/$cpanel_username/www" ]; then
        log "Removing symlink /home/$cpanel_username/www (since www is a symlink to public_html)."
        if rm /home/$cpanel_username/www; then
            log "Successfully removed symlink /home/$cpanel_username/www."
        else
            log "ERROR: Failed to remove symlink /home/$cpanel_username/www."
        fi
    else
        log "WARNING: /home/$cpanel_username/www does not exist or is not a symlink. Skipping removal."
    fi
}

This was result:

When was the last time this scripted worked? when did u check it?

stefanpejcic commented 2 hours ago

Backup Is from cpanel wizard?

I'll run tests