以cPanel用户身份通过SSH创建全量备份的可行方案咨询
Great question! Let's break this down clearly: you can’t use root-level cPanel backup APIs as a regular cPanel user, but there are totally valid ways to create a full account backup via SSH—exactly like you would through the cPanel web interface. Here’s how to do it:
1. Use cPanel's UAPI (User API) via curl
The cPanel UAPI includes a Backup::fullbackup function built specifically for regular users to trigger their own full account backups. This is the exact same tool the cPanel web interface uses behind the scenes.
Run this curl command directly in your SSH session:
curl -u "your_cpanel_username:your_cpanel_password" "https://your-cpanel-domain.com:2083/execute/Backup/fullbackup" \ -d "email=your-notification-email@example.com" \ -d "backup_destination=homedir" \ -d "enable_homedir=1" \ -d "enable_mysql=1" \ -d "enable_email=1"
Key parameter breakdown:
backup_destination: Set tohomedirto store the backup in your account’s main directory, or useftp/s3if you want to send it to external storage.enable_homedir/enable_mysql/enable_email: Toggle whether to include your website files, MySQL databases, and email accounts respectively.email: Gets notified once the backup completes (critical, since backups can take time for large accounts).
For better security, replace your password with an API Token (generate one in cPanel’s "API Tokens" section). The command becomes:
curl -u "your_cpanel_username:your_api_token" "https://your-cpanel-domain.com:2083/execute/Backup/fullbackup" \ -d "email=your-notification-email@example.com" \ -d "backup_destination=homedir"
2. Use the uapi command-line tool
Most cPanel servers have the uapi CLI tool pre-installed for regular users. This is even simpler than curl—just run:
uapi --user=your_cpanel_username Backup fullbackup \ email=your-notification-email@example.com \ backup_destination=homedir \ enable_homedir=1 \ enable_mysql=1
This triggers the exact same full backup process as the web interface, and you’ll get an email when it’s finished.
Important Notes
- Permissions Check: Make sure your host hasn’t disabled user-level backups. Some providers restrict this feature, so if you get errors, reach out to their support to confirm.
- Backup Storage: If you choose
homediras the destination, the backup file will appear in your main directory with a name likebackup-YYYY-MM-DD_HH-MM-SS_yourusername.tar.gz. Remember to download it to external storage eventually, as it counts against your account’s disk quota. - Time Requirements: Backup speed depends on your account size (large sites/databases will take longer). Don’t panic if it doesn’t finish immediately—wait for the notification email.
To sum it up: You don’t need root access to create a full backup of your own cPanel account via SSH. Using UAPI (either via curl or the uapi CLI) lets you replicate the exact same backup process as the cPanel web interface.
内容的提问来源于stack exchange,提问作者ipel

