Time Machine works to backup Apple Notes on macOS, but I also want:
Backup your Notes and computer.
Copy your Notes folder to a working directory
mkdir notes-test
cd notes-test
cp -r /Users/$USER/Library/Group\ Containers/group.com.apple.notes ./
Download the tool made by threeplanetssoftware:
git clone https://github.com/threeplanetssoftware/apple_cloud_notes_parser.git
# Or use my branch to skip table parsing and fix linebreaks/indentation:
https://github.com/lawm/apple_cloud_notes_parser
cd apple_cloud_notes_parser
# Install ruby, bundle, and other dependencies
sudo apt-get install build-essential libsqlite3-dev zlib1g-dev git ruby-full ruby-bundler
bundle install
Run the tool to convert from Apple's Notes format to a more readable and portable format.
ruby notes_cloud_ripper.rb -m ../group.com.apple.notes
The output will include
output/TIMESTAMP/NoteStore.sqlite
$ sqlite3 NoteStore.sqlite
sqlite> .tables
sqlite> select * from ZICNOTEDATA;
output/TIMESTAMP/all_notes_1.html
output/TIMESTAMP/files/
Now the output/TIMESTAMP
folder can be zip'd and backed up to the location of your choice.