Skip to content

Commit 40e36f5

Browse files
committed
Backup command added. fixes #21
1 parent adfe3d1 commit 40e36f5

File tree

6 files changed

+32
-2
lines changed

6 files changed

+32
-2
lines changed

docs/RELEASE-NOTES.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
# STANDARD(?) UNIX NOTES
22
# RELEASE NOTES
33

4+
2.4
5+
- Added backup sub-command (creates GnuPG encrypted
6+
tarball in HOME)
7+
48
2.3
59
- Added GNU shred(1) for file deletion where available
610
- fixed bug #26 (wrong extension for 'edit' -> .asc)

docs/ROADMAP.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
44
ROADMAP
55

6+
2.4 Added backup sub command
7+
68
2.3 Use GNU shred(1) where available
79

810
2.2 Migrate to ascii encoded GPG files (see RELEASE-NOTES.md)
@@ -48,6 +50,5 @@ FUTURE FEATURES
4850
- zsh completion
4951
- FreeBSD .PKG packaging
5052
- FreeBSD ports configuration
51-
- encrypted backup/restore
5253
- PIV card support
5354
- Issue #17 BUG - import truncates filename if spaces in filename

docs/USING_NOTES.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,10 @@ $ ykman openpgp set-touch enc cached
5151
```
5252

5353

54+
## Sub-command backup
55+
56+
Backup your notes and journal entries to a GPG encrypted tar file (in $HOME)
57+
5458
## Sub-command add | insert
5559

5660
To add a note simply issue the command

docs/journal.1

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,8 @@ the KEYID of the private key you wish to use.
7878
issues with other keys, then run \fBnotes newkey <keyid>\fP. Notes will
7979
replace the keyid automatically in the config file.
8080

81+
Journal entries can be backed up using the backup sub-command of notes(1).
82+
8183
.SH SHELL INTEGRATION
8284

8385
Standard Unix Notes system supports bash completion for notes(1),

docs/notes.1

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,14 @@ Displays the config file
8585
~/.notes/config
8686
to the terminal. This is a quick way of determining that GPG KeyID is in use.
8787

88+
.SY backup
89+
.YS
90+
91+
Backup your notes directory to a GPG encrypted tar file placed in your
92+
$HOME directory. Backups can be tested using the following command:
93+
94+
$ gpg -d ~/unix-notes-backup-20210630_1503.tar.asc | tar tv
95+
8896
.SY help
8997
.YS
9098
Displays a quick help page displaying available commands.

notes

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,8 @@ GPG_OPTS=" --quiet --yes --compress-algo=none --no-encrypt-to"
2828
GPG="gpg"
2929
EDITOR="${EDITOR:-nano}"
3030
PAGER="${PAGER:-more}"
31-
31+
TIMESTAMP="`date \"+%Y%m%d_%H%M\"`"
32+
BACKUPFILE="${HOME}/unix-notes-backup-${TIMESTAMP}.tar.asc"
3233
# Use shred if available
3334
SHRED="`which shred`"
3435
if [ $? = 0 ]; then
@@ -370,6 +371,7 @@ GPG encrypted notes system for BSD and Linux systems
370371
371372
notes init initialise notes system
372373
notes config display config file
374+
notes backup backup $NOTESDIR to GPG encrypted tar file
373375
notes newkey email change GPG key
374376
notes help show help
375377
notes version show version
@@ -435,6 +437,14 @@ cmd_config () {
435437
echo The Journal uses the directory $JOURNALDIR
436438
}
437439

440+
cmd_backup () {
441+
442+
get_recipient
443+
444+
echo running tar backup to $BACKUPFILE
445+
tar cv ${NOTESDIR} | gpg -ear ${KEY} ${GPGOPTS} > ${BACKUPFILE}
446+
}
447+
438448
cmd_tree () {
439449
tree -I Journal ${NOTESDIR}
440450
}
@@ -630,6 +640,7 @@ COMMAND="$1"
630640
case "$1" in
631641
init) shift; cmd_init "$@" ;;
632642
config) shift; cmd_config "$@" ;;
643+
backup) shift; cmd_backup ;;
633644
tree) shift; cmd_tree ;;
634645
licence|license) shift; cmd_licence "$@" ;;
635646
default) shift; cmd_default "$@" ;;

0 commit comments

Comments
 (0)