CloudLinux.ro
Storage & files

How to encrypt files and backups

Updated 7/20/2026

Backups often contain sensitive data. If you store them off the server, encryption makes them useless to anyone without the password.

Encrypt a file with GPG

gpg -c backup.tar.gz

You get backup.tar.gz.gpg, protected with a password. Decrypt:

gpg backup.tar.gz.gpg

Encrypt during the backup

mysqldump -u root -p app_db | gzip | gpg -c > app_db.sql.gz.gpg

The data is encrypted before it touches the disk, useful when sending a backup to a Backup Box.

Key-based encryption (no interactive password)

For automated scripts, use a GPG public key instead of a password:

gpg --encrypt --recipient [email protected] backup.tar.gz

Important rules

  • Keep the password or private key separate from the backups; without it, the data is lost permanently.
  • Test decryption periodically, a backup that cannot be decrypted is worthless.
  • Combine with automated backups with cron.

Put this guide into practice on your own VPS

EU cloud servers, billed hourly, ready in minutes, with one-click installs for dozens of apps.

See pricing

Related tutorials