Upgrading
How to back up encrypted data and upgrade the agent once it's installed. Covers both TFE Local Directory and TFE Object Storage, with differences called out as they come up.
1. Backing Up Encrypted Data
TFE Local Directory
The .encrypted companion folder keeps encryption information in special file attributes (extended attributes / xattr). Use a backup tool that drops those attributes, and you end up with a backup you can never decrypt again.
# correct - preserves extended attributes
tar --xattrs --xattrs-include='user.*' -cf backup.tar /var/lib/mysql.encrypted
rsync -aX /var/lib/mysql.encrypted/ /backup/mysql.encrypted/
cp -a /var/lib/mysql.encrypted /backup/mysql.encrypted
Avoid tar -cf (without --xattrs), rsync -a (without -X), and cp -r. They silently drop the extended attributes, and the resulting backup can't be decrypted.
Always back up the .encrypted folder, never the application-facing one. The application-facing folder only gives you decrypted plaintext, not what's actually stored on disk.
Additional safeguard: export and check the encryption records
# export the encryption records of a protected folder
sudo takakrypt-fte export-records /var/lib/mysql.encrypted -o /backup/mysql-records.bin
# check for files that have lost their encryption records
sudo takakrypt-fte check-metadata /var/lib/mysql.encrypted
If the records turn out to be missing after a restore, bring them back from the exported copy. Stop the agent first:
sudo systemctl stop takakrypt-fte
# test first without changing anything
sudo takakrypt-fte import-records /var/lib/mysql.encrypted -i /backup/mysql-records.bin -n
# restore
sudo takakrypt-fte import-records /var/lib/mysql.encrypted -i /backup/mysql-records.bin
sudo systemctl start takakrypt-fte
- The exported copy doesn't contain encryption keys, so nobody can use it to open the files.
- Files whose records are still intact aren't changed.
- Encryption keys aren't part of the backup. Restored data can only be opened by an agent that is still registered and connected to the gateway.
If a file comes back from a restore without its encryption record, don't run takakrypt-fte ldt scan by hand until you know whether the record exists. The automatic scan leaves such a file alone, but a manual scan treats it as new plaintext and encrypts the ciphertext again, which destroys it. Restore the file from a backup that carries its record. Run check-metadata before starting the agent to find these files.
The -force option on import-records overwrites everything back to the state when the copy was made, so anything more recent gets lost. Use it only if truly necessary.
TFE Object Storage
For a MinIO or Amazon S3 backend, lean on the backup features the object storage service already offers: replication, versioning, snapshots. Copy files directly from object storage, not through TFE Object Storage, since reading through it returns decrypted plaintext.
For a local storage backend, back up the storage folder directly on the server.
sudo cp -a /var/lib/takakrypt/fos/storage /path/backup/
2. Upgrading the Agent
You don't need to run uninstall.sh to upgrade. Just run the installer again on the server that already has the agent:
# TFE Local Directory
sudo ./install.sh fte
# TFE Object Storage
sudo ./install.sh fos
This is tested and safe. It preserves the encryption journal (.encrypted record for TFE Local Directory, bucket metadata for TFE Object Storage). A running agent restarts automatically after the upgrade, even without --start. Add --skip-config to keep the existing configuration on the server as is, without being asked again.
Rekeying a Bucket (TFE Object Storage only)
Only use this to raise the key version of a bucket already on key version 2 or later.
sudo systemctl stop takakrypt-fos
sudo takakrypt-fos --rekey-bucket my-bucket
sudo systemctl start takakrypt-fos
It only touches files encrypted with aes-cbc-cs1 (≤10 MB). Larger aes-gcm files get skipped. Stop any application writing to the bucket while this runs, and once it's done, it reports how many files succeeded, were skipped, or failed.
Need to remove the agent instead? See Uninstalling. For the configuration file reference, see Agent Configuration.