In order to make a backup of all my certs, i want to copy the whole letsencrypt folder then compress it and lastly send them to S3.
Im thinking of using the cp -a command which they tell me preserves symlinks and pretty much everything within the folder structure (permissions for example).
After that i would like to use the tar -czf command in order to compress the folder before sending it to S3
Is this a sane and straightforward way of doing this?
Also, a different question: what is the advantage of using rsync instead of cp -a i mean cp -a it’s pretty straight forward. Why would i want to use rsync in this case? (to backup the whole letsencrypt folder for example) .
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.