# Import a cPanel backup

> Source: https://www.allsweb.com/sixpanel/docs/import-from-cpanel
> Markdown for agents: https://www.allsweb.com/sixpanel/docs/import-from-cpanel.md
> Publisher: AllsWeb (www.allsweb.com)

Part of: SixPanel documentation

Moving away from a cPanel host? SixPanel can take a cPanel account backup and make
everything in it here: each website with its files and databases, the mailboxes with
their messages and passwords, the forwarders, and the scheduled jobs. Nothing is made
until you have seen what the backup holds and pressed **Import**. Afterwards every part
is checked against the backup, and you get a report.

Where: **Migration → Import from cPanel**. Only the server's owner login can import.

## 1. Make the backup on the old server

Any one of these gives the right file:

- **cPanel → Backup → Download a Full Account Backup.** Choose *Home Directory* as the
  destination. When cPanel emails you, download the file
  `backup-<date>_<user>.tar.gz` from your home folder.
- **WHM → Backup** (or *Transfer Tool → Package Account*) if you run the server. The
  file is `cpmove-<user>.tar.gz`.

SixPanel takes the file as it comes, its name ending `.tar.gz` or `.tgz`.

Make it with the home directory included. A backup made with "skip home directory"
has no website files, and SixPanel says so instead of importing it.

## 2. Bring it to this server

- **Upload it** on the tab: choose the file and press **Upload and read it**. Big files
  go up in pieces, and a slow connection is fine.
- **A very big backup** can go over SSH instead. Make the folder once, then copy the file:

      sudo install -d -o root -g root -m 0700 /var/tmp/sixpanel-imports
      scp backup-*.tar.gz root@<this server>:/var/tmp/sixpanel-imports/

  Then choose it under **Or use a file on this server** and press **Read it**. SixPanel
  only reads that folder while root alone can write to it, and the tab tells you if
  it cannot.

## 3. See what it holds

Reading changes nothing on this server. The tab then lists:

- **Websites**: the main domain with its parked domains, every addon domain and
  subdomain that has a folder of its own, and whether each is WordPress or plain PHP.
  An addon domain inside `public_html` becomes its own website and is not copied twice.
- **Databases**, each next to the website whose settings file names it. A database no
  website names goes with the main website, so nothing is left behind.
- **Mailboxes and forwarders**, the domains they are for, and how many mailboxes will
  need a new password (see below). Only the account's own domains are read: mail the
  backup holds for any other domain is left out.
- **Cron jobs**, each given to the website whose folder it runs in.
- **Not imported, and why**: each thing that stays behind, in one line.

A website whose address is already used on this server cannot be ticked. That line
says which website here has the address. The addresses are asked again when you press
**Import**, so one given to another website in the meantime stops the import with the
same line.

## 4. Import

Untick anything you do not want, choose whether to **Bring the mail too**, and press
**Import**. Each website is then:

1. made with its own account, folder, PHP and database, the same as one you create here;
2. given its files and its databases. `wp-config.php` (WordPress) or an app's `.env`
   that names its old database is changed to name the one here;
3. served on its addresses;
4. given its scheduled jobs, with cPanel's PHP paths (`/usr/local/bin/php`,
   `ea-php82` …) changed to the website's own PHP, and the website's old folder
   (`/home/<user>/public_html/…`) changed to the website's folder here. A job runs in
   that folder, so `php /home/bob/public_html/cron.php` becomes `php cron.php`;
5. **checked against the backup**: the same files, the same rows in every table of
   every database, the same scheduled jobs, and whether it answers here. Its home page
   is asked of the website's own PHP, the way visitors will reach it once its
   certificate is in place, so a page that stops on an error (HTTP 500) shows as a
   failed check now, not after you move the DNS.

Mailboxes keep their password. Use the same one as before in the mail app.
Their messages and folders are copied, and each mailbox's message count is checked.
A backup with forwarders and no mailbox brings its forwarders too.

Before a website's files are copied, SixPanel checks the disk has room for them twice
(they are staged, then put in place) above the space it always keeps free for the
database and the logs. A database kept compressed in the backup (`mysql/<db>.sql.gz`)
counts at the size it unpacks to, measured while the backup is read. A website that does
not fit is not started, and the line says how much it needs. The mail gets the same
check before its first mailbox is made: if its messages do not fit, the mail is not
imported and the report says how much it needs.

A website that fails is removed again, so nothing half-made stays. The others go on.
When only part of a backup comes in, its card says **Imported, with failures**: each part
that did not come in reads **Did not come in** with its reason, and the parts that came in
keep their verdict.
When nothing of an import comes in (every website fails, and the mail too when it was
brought), its card under **Imports** says **The import failed** and gives each part's
reason; **Could not be read** is only for a backup that could not be unpacked or read.
Mail that came in while every website failed counts as imported: the card's report
lists the websites that failed.
The unpacked backup is deleted from this server when the import ends.

If the panel restarts during a read or an import (an update, a reboot), the import is
marked as stopped, a website it had only half made is removed, and you can upload the
backup again at once.

Your DNS is not changed. When a domain points at this server, its website gets its
HTTPS certificate by itself within a few minutes. Point the mail records (MX, SPF,
DKIM) the way **Email → the domain** shows.

## 5. Read the report

The import shows up under **Imports**, with the same card a move between servers uses:
each website and the mail, each check with the backup's number and this server's, how
long each part took, and **Download the report** / **Download the log**. A row in
red names what differed. The log is kept with your other migrations.

## What stays behind, by design

- **A 6amMart shop** (the untouched CodeCanyon code or a changed copy alike). A shop
  needs its storage, its keys and its database carried the way 6amMart expects. Make a
  project, then on its **Deploys** press **Put 6amMart on this project → A project that
  already runs somewhere** ([Bring your shop here from files](https://www.allsweb.com/sixpanel/docs/bring-your-shop-here)),
  or use [Move an existing site here](https://www.allsweb.com/sixpanel/docs/move-existing-site) if you have SSH to the old
  server. The import names the shop and leaves it.
- **A mailbox password cPanel kept in an old format** (DES). That mailbox is made
  without a password. Set one on **Email** before it signs in.
- **Forwarders to a program** (`|/home/…/script.php`), `:fail:` lines and the
  catch-all. Set a catch-all on **Email → the domain** if you want one.
- **`@reboot` jobs.** Add one as an always-running job on the website's **Cron** page
  if you still need it.
- **WordPress's own `wp-cron.php` job.** SixPanel already runs WordPress's scheduler
  every 5 minutes.
- **Links out of a website's folder** (cPanel's `access-logs`, links into other
  folders of the old home). They pointed at things this server does not have.
  A link that stays inside the folder but is written with `..` after a folder name
  (`assets/../css/app.css`), or that goes above the website's folder on its way back
  into it (`../public_html/css/app.css` at the top of `public_html`), is left out too:
  the copy onto this server does not make such links. Each one is named in the log, so
  the files still check out the same.
- **A scheduled job that runs a file outside every website's folder** (for example
  `/home/bob/backup.sh`). That file is not part of any website here. Put it in the
  website and add the job on its **Cron** page.
- **Mail of a domain that is already a mail domain on this server.** Its mailboxes and
  forwarders belong to whoever has that domain here, so none are added. Add the ones you
  want on **Email → the domain**. The plan says so before you import, and the report
  marks it.
- **Mail of a name another website, a project or the panel already uses here**, unless
  you tick it. The plan lists each such domain under the mail with the website that
  serves it, and a tick of its own, which is not ticked. Tick it when that website is
  yours: one an earlier import of this same backup made, or one you moved here another
  way. Its mailboxes then come with their passwords and messages, and the report says
  you ticked it. Leave it unticked when the website is somebody else's: a backup could
  otherwise add a mailbox, with a password it chose, to a domain that is not its own.
- **Mail of a domain that is not one of the account's own.** Only the main, parked,
  addon and subdomains of the cPanel account are read.

## Safety

The backup comes from another server, so SixPanel treats it as untrusted until it has
been read. It is unpacked into a folder only the server's administrator can read, and
it is refused before anything is written if it holds any of these:

- a name that climbs out of it (`../`) or an absolute path;
- a file placed under one of its own links;
- a hard link to something outside it;
- a device or a pipe;
- the same file twice, under any spelling of its name;
- more data than the disk has room for (a "zip bomb" is stopped while it unpacks).
  A compressed database dump inside it is measured unpacked too: one that would not
  fit, or that names more than 100,000 tables, stops the website it belongs to before
  anything is copied;
- more files than the disk has free entries for, so millions of empty files cannot
  fill it while it still shows free space.
- a table of contents longer than 256 MB, which no website's backup has: one built
  that way would fill the server's memory while it is read.

Each database is imported as its website's own database user, never as root.

## If something goes wrong

- **"this is not a cPanel account backup"**: the file is not a full account backup
  (for example a *home directory only* or *databases only* backup). Make a full one.
- **"keeps the home folder as homedir.tar"**: the backup is from a cPanel older than
  version 102. Make it again on that server, or unpack `homedir.tar` into a
  `homedir` folder and pack the backup again.
- **"SixPanel Email is not installed"**: install Email first, or untick **Bring the mail too**.
  To bring the mail later, install Email and read the same backup again. Its websites
  are here already, so they cannot be ticked; tick each of its domains under the mail,
  and press **Import**.
- **A website reads NOT VERIFIED**: open its card. The row in red says what differed.
  Fix it, delete that website and import again. The backup is read again in a minute.
