Best Way to Backup letsencrypt folder

Hello @lmuzquiz,

There is no need to use cp -a and then tar, you can use tar directly:

tar zcvf /tmp/letsencrypt_backup_$(date +'%Y-%m-%d_%H%M').tar.gz /etc/letsencrypt

Previous command will preserve perms (if you launch the command as root) and by default, tar preserves symlinks so you will have a perfect backup for your /etc/letsencrypt/ directory. The date part of the command will save the date and time when you created the tar file.. for example /tmp/letsencrypt_backup_2016-10-23_0114.tar.gz .

You can check the content of tar file using command:

tar tvf /tmp/letsencrypt_backup_2016-10-23_0114.tar.gz

In case of disaster you can recover your /etc/letsencrypt/ dir using this command (change /tmp/letsencrypt_backup_2016-10-23_0114.tar.gz by the right path and file name):

tar zxvf /tmp/letsencrypt_backup_2016-10-23_0114.tar.gz -C /

They are different tools, both of them can perform a backup of /etc/letsencrypt/ in the same computer of course but rsync main goal is to syncronize files and dirs between remote computers so... it will depends on what you want to achieve and how you plan to upload your backup to S3.

Cheers,
sahsanu

3 Likes