Set up automatic backups to the CCN Backup Space Print

  • backup, restauration, cle ssh, rsync, serveurs, sauvegarde, espace de sauvegarde
  • 0

This guide explains, step by step, how to automatically send a nightly copy of your server (files and databases) to your CCN Backup Space, and how to get your data back. Allow about 20 minutes.

What you need

  • An active CCN Backup Space (order at ccntechnologies.com/en/espace-sauvegarde.php).
  • A Linux server (VPS, dedicated server) or a Linux/macOS computer with rsync and ssh. On Windows, use WSL (Windows Subsystem for Linux).
  • Command-line access to that server (SSH or terminal).

To check that rsync is installed, type rsync --version. If it is missing: apt install rsync (Debian, Ubuntu) or dnf install rsync (AlmaLinux, Rocky, CentOS).

Step 1: open "My backup"

  1. Log in to your client area.
  2. Open My services, then your backup space.
  3. Click Open "My backup". You will find your used space, your username, the server address (backup.ccntechnologies.com) and the key form.

Step 2: create an SSH key on your server

ssh-keygen -t ed25519 -f ~/.ssh/ccn_sauvegarde -N ""
cat ~/.ssh/ccn_sauvegarde.pub

The second command prints a line starting with ssh-ed25519: this is your public key. Copy the whole line.

Important: never copy the ccn_sauvegarde file (without .pub). It is your private key and must stay on your server.

Step 3: register the key

  1. In "My backup", paste the line into the Register my SSH key field.
  2. Click Save the key.
  3. Wait about a minute: the status changes to Active.

Step 4: first upload

Replace USERNAME with the username shown in "My backup". Example for a site in /var/www/:

rsync -az --delete -e "ssh -i ~/.ssh/ccn_sauvegarde" /var/www/ [email protected]:www/

On the first connection, answer yes to accept the server. The first upload copies everything; the next ones only send changes. All paths start from your personal space; you cannot see or write anything outside it.

Step 5: back up your databases

mkdir -p /root/dumps
mysqldump --all-databases --single-transaction | gzip > /root/dumps/bases-$(date +%u).sql.gz
rsync -az -e "ssh -i ~/.ssh/ccn_sauvegarde" /root/dumps/ [email protected]:bases/

The day-of-week number in the file name keeps 7 versions of your databases (one per day).

Step 6: automate every night

Type crontab -e and add these two lines at the end:

15 2 * * * mysqldump --all-databases --single-transaction | gzip > /root/dumps/bases-$(date +\%u).sql.gz
30 2 * * * rsync -az --delete -e "ssh -i /root/.ssh/ccn_sauvegarde" /var/www/ [email protected]:www/ && rsync -az -e "ssh -i /root/.ssh/ccn_sauvegarde" /root/dumps/ [email protected]:bases/ >> /var/log/ccn-sauvegarde.log 2>&1

The next day, check in "My backup" that the last upload date has changed. Space is measured every night.

Restoring your data

rsync -az -e "ssh -i ~/.ssh/ccn_sauvegarde" [email protected]:www/ /var/www/
rsync -az -e "ssh -i ~/.ssh/ccn_sauvegarde" [email protected]:bases/ /root/restore/
gunzip -c /root/restore/bases-3.sql.gz | mysql

Test a restore from time to time, for example into a test folder: it is the only way to be sure your backups are usable.

Good to know

  • Limits: space (200 GB, 1 TB, 2 TB…) and a maximum number of files (50,000 for 200 GB, 80,000 for 1 TB, 120,000 for 2 TB, 400,000 from 4 TB). Many small files? Bundle them: tar czf site.tar.gz /var/www/.
  • Alerts: you get an e-mail at 80% and 100%. Beyond a small overrun, uploads are blocked but downloads remain possible.
  • Changing your key: paste the new key in "My backup"; the old one stops working within a minute.
  • Access: rsync over SSH with your key only. There is no password, no FTP and no control panel.
  • After cancellation your data is kept for 7 days; after suspension for non-payment, 15 days. Always keep another copy of important data.

Troubleshooting

  • "Permission denied (publickey)": the key is not active yet (wait a minute after saving it) or it is not the right key. Check that the end of the key shown in "My backup" matches your .pub file and that the command uses -i ~/.ssh/ccn_sauvegarde.
  • "rsync: command not found": install rsync (see above).
  • Error with a nested folder (e.g. server1/www/): first create the parent folder by uploading to server1/, or use a single level (www/).
  • Uploads stop: your space may be full. Check the status in "My backup" and your alert e-mails.

Need help? Open a ticket from your client area. Our assistant Ange answers online 24/7, and our team takes over during office hours.


Was this answer helpful?

« Back