November 17, 2023

Backup /etc/letsencrypt directory with rsync from remote server to local machine

$ mkdir letsencrypt_backup
$ cd letsencrypt_backup
$ rsync -chavP --stats root@redacted_IP_address:/etc/letsencrypt .

I found this rsync command online first, modified it and checked on the forum of Let’s Encrypt to see what other users thought. The feedback I got was to pass an option that preserves symlinks, so either -l, or -a which enables it.

You can run man rsync to see what each option does.

Then you can create an executable file that you can run each time you want to back up certificates (when you create a new website, for example).

If $ rsync -chavP […] was the last command you run, you can run:

$ echo !!:q > backup

This will create a file named backup containing the rsync command.

See https://yctct.com/copy-history-file for more examples and some explanations about this last command.

Then you need to make this file executable, to do so, run:

$ chmod +x backup

Now you can run:

$ ./backup

to backup yours Let’s Encrypt certificates.

When rsync see there is nothing to be incremented, you should see something like this:

receiving incremental file list

Number of files: 1,181 (reg: 1,074, dir: 47, link: 60)
Number of created files: 0
Number of deleted files: 0
Number of regular files transferred: 0
Total file size: 2.74M bytes
Total transferred file size: 0 bytes
Literal data: 0 bytes
Matched data: 0 bytes
File list size: 51.22K
File list generation time: 0.001 seconds
File list transfer time: 0.000 seconds
Total bytes sent: 79
Total bytes received: 57.83K

sent 79 bytes  received 57.83K bytes  38.61K bytes/sec
total size is 2.74M  speedup is 47.28

personal computing command-line interface (cli) gnu linux trisquel shell literacy wiki hosting rsync letsencrypt certbot

No affiliate links, no analytics, no tracking, no cookies. This work © 2016-2025 by yctct is licensed under CC BY-SA 4.0 .   about me   contact me   all entries & tags   FAQ   GPG public key

GPG fingerprint: 2E0F FB60 7FEF 11D0 FB45 4DDC E979 E52A 7036 7A88