Use this guide to compress and restore individual cPanel account backups manually from a cPremote-style folder structure.
1. Navigate to the Backup Directory
Go to the location where the account data is stored. For example:
cd /home/secondbackup/monthly/accounts/europe/homedir/daily/accounts
2. Compress the Account Folder
Use tar
to compress the account directory. Replace example1
with the actual cPanel username:
tar -zcvf example1.tar.gz example1
- This creates a compressed archive named
example1.tar.gz
containing the account’s backup files.
3. Copy the Compressed File to the New Server
You can use scp
or rsync
to transfer the backup file:
scp example1.tar.gz root@NEW_SERVER_IP:/home/
Or if using a custom SSH port (e.g., 2500):
scp -P 2500 example1.tar.gz root@NEW_SERVER_IP:/home/
4. Restore the Account on the New cPanel Server
SSH into the new server and run:
cd /home
tar -zxvf example1.tar.gz
/scripts/restorepkg example1
This restores the cPanel account using the extracted folder.
✅ Tip: Ensure the backup contains all required files (
homedir
,cp
,mysql
, etc.) for a full account restoration.
Here’s how to automate compression and restoration of multiple cPanel accounts using the cPremote folder structure.
Automate Compressing and Restoring Multiple cPanel Accounts
This script compresses each account in a directory and allows you to restore them one by one on a new server.
1. Compress All Accounts (Local Server)
Create and run the following script:
#!/bin/bash
# compress_accounts.sh
BACKUP_DIR="/home/secondbackup/monthly/accounts/europe/homedir/daily/accounts"
cd "$BACKUP_DIR" || exit
for account in *; do
if [ -d "$account" ]; then
echo "Compressing $account..."
tar -zcvf "${account}.tar.gz" "$account"
fi
done
Run the script:
bash compress_accounts.sh
All accounts will be compressed into .tar.gz
archives in the same folder.
2. Transfer All Archives to New Server
Use rsync
(or scp
) to copy all .tar.gz
files:
rsync -avP /home/secondbackup/monthly/accounts/europe/homedir/daily/accounts/*.tar.gz root@NEW_SERVER_IP:/home/
3. Restore All Accounts (New Server)
Create this script on the new server to extract and restore each account:
#!/bin/bash
# restore_accounts.sh
cd /home || exit
for archive in *.tar.gz; do
account=$(basename "$archive" .tar.gz)
echo "Restoring $account..."
tar -zxvf "$archive"
/scripts/restorepkg "$account"
done
Run the script:
bash restore_accounts.sh
✅ Tips
- Ensure backups have full account data (
cp
,mysql
,homedir
, etc.). - You can add
rm -rf "$account"
at the end of the restore script to clean up extracted folders after restoration. - Test one account manually first before bulk operations.