Blog | G5 Cyber Security

Secure Offsite Backups

TL;DR

Back up your data to a distant server using encryption *before* sending it. This way, even if the server is compromised, your backups remain unreadable without the decryption key.

Secure Offsite Backups: A Step-by-Step Guide

  1. Choose an Encryption Method
  • Generate an Encryption Key Pair (GPG Example)
  • This creates a public and private key. Keep your private key extremely safe!

    gpg --gen-key

    Follow the prompts to create a strong passphrase for your key.

  • Encrypt Your Data
  • gpg -e -r "Your Name" filename.txt

    This encrypts filename.txt using your public key, creating filename.txt.gpg.

  • GPG (Directory):
  • tar -czvf directory.tar.gz directory && gpg -e -r "Your Name" directory.tar.gz

    This creates a compressed archive of the directory and then encrypts it.

  • OpenSSL (Example):
  • openssl enc aes-256-cbc -salt -in filename.txt -out filename.enc

    You’ll be prompted for a password. Use a strong one!

  • Transfer the Encrypted Data to Your Distant Server
  • scp filename.txt.gpg user@server_ip:/path/to/backup/directory
  • SFTP (Secure File Transfer Protocol): Similar to SCP but provides more features.
  • rsync over SSH: Efficient for incremental backups.
  • Verify the Backup on the Distant Server
  • Decrypt Your Data (Test Recovery)
  • gpg -d filename.txt.gpg > filename.txt

    You’ll be prompted for your private key passphrase.

  • OpenSSL:
  • openssl enc aes-256-cbc -d -salt -in filename.enc -out filename.txt

    You’ll be prompted for the password you used during encryption.

  • Automate Backups (Important!)
  • 0 2 * * * /path/to/your/backup_script.sh
  • Key Management is Crucial
  • Exit mobile version