Initializes a backup area:Choosing a Passphrase
$ hb init -c backupdir [-k key] [-p ask/env]
The init command creates and initializes the backup directory. If the directory already exists, it must be empty or init will complain. This avoids overwriting a directory by mistake.
During initialization, an inex.conf file will be created, listing files that should be excluded from the backup. You may want to review and modify this before your first backup.
The -k option specifies your own encryption key. Normally a random key is generated by init, and -k is not recommended. But in some environments you may want a common key for several backups, a key that's easier to remember, or may want a blank key. These are all less secure than a random key, but it may be less likely that the key is lost. A key with special characters will require quotes, for example: -k 'my special key'. Spaces are always ignored in keys, so the key abcdef is equivalent to abc def. To set a blank key, use -k '' (two single quotes). The key can be changed later with the rekey command.
The -p option adds a passphrase to your key. -p ask means to get the passphrase from the keyboard. Every hb command will ask for the passphrase. -p env means to read the passphrase from a shell or environment variable named HBPASS.
It is recommended to use a local directory with -c. If you are tight on disk space, use the cache-size-limit config option to conserve space in the backup directory.
IMPORTANT: if you do back up directly to remote storage (the -c backup directory is on remote storage), the encryption key is also stored here. If you don't own & control the remote storage, for example, you are backing up directly to Google Drive with -c, it is important to use a passphrase to protect your backup.
All of HashBackup's security comes from your key. This is why hb init creates a random key by default: it is next to impossible for someone to guess a long random key. Here are some suggestions for creating a strong passphrase to further protect your key:
Creating Backups With a Common Key
You may want several backup directories with the same key. Here is the procedure:
Create a backup directory with hb init. If you already have a backup directory, skip this step.
$ hb init -c hb
Display the key file:
$ cat hb/key.conf
For all of the backups you want to have the same key, including the one you just displayed, use the hb rekey command. The backup can have data or be empty. You can copy and paste the key value using Ctrl-C (Command-C on Mac) and Ctrl-V (Command-V on Mac). There is a warning displayed about this being less secure, but that is not really true in this case because instead of choosing a key value, you originally did let HashBackup pick a random key.
$ hb rekey -c hb -k '3b93 2b0b bf19 3f3d 925a 0f71 d5cf 3034 6b0b a14b e9f3 540e 6f1c 86aa 1687 3ae7'
Now what does the key file look like?
$ cat hb/key.conf
Repeat the rekey operation on every backup you want to have identical keys. After rekey, all of the key.conf files will have the same Keyfrom and Key fields. In the future, create new backup directories with hb init and then use hb rekey with -k to make the key identical to your other backups. If you prefer, you can choose your own common key to use with rekey, but as the warning says, this will be less secure than HashBackup creating a random key. You cannot copy key files to different backup directories and cannot use an editor to change Keyfrom from "random" to "user" in the key.conf file.