2024-11-14 Setting Up memos
In the process of building up my home lab and writing posts at the same time, I also use this blog site for quick note taking. It is time to check out what's out there that can help me keep notes and ideas, and access them from different devices. I will try memos, which seems to check a lot of boxes for me.
Setting Up memos
There are popular open-source self-hostable choices in addition to memos, such as Nextcloud Notes, Joplin, Flatnotes, etc. memos seems light-weight and feature rich enough, providing access from mobile phones too. So let us start with it.
Since memos is usually installed via Docker, visit their installation page and follow along:
mkdir memos
cd memos
Create the docker-compose.yaml
file:
dnetworks:
mynet:
name: mynet
external: true
services:
memos:
image: neosmemo/memos:stable
container_name: memos
volumes:
- ./data/:/var/opt/memos
ports:
- 5230:5230
networks:
- mynet
Launch the container and see if it works:
$ docker-compose up -d && docker-compose logs -f
Initially I cannot create the first user and login. It seems to not accepting two-letter usernames. So I start over using a longer username and it works:
Since this is for internal use, I will adjust the docker-compose.yaml
file to serve it only on my Nebula network.
By this time I am more aware of the use of the firewall groups in Nebula. For services behind NPM, I do not use the host's ports if possible. For local services running only over Nebula, exposing ports on the network (e.g.192.168.111.0/24
) is needed. But since headless servers and VPSs do not need to access the web interface of a particular service, a group in Nebula can be created to contain only the machines where web interface is needed. In this case only these devices can access port5230
.
Backup
Since we only set up memos to use SQLite, the backup plan is like what we did previously.The script backup.sh
placed next to docker-compose.yaml
needs minimal change:
#!/bin/bash
# Set the script to exit immediately if any command fails
set -e
DATE=$(date +%Y-%m-%d)
BACKUP_DIR=~/.../syncthing/data/Backups/memos
BACKUP_FILE=memos-$DATE.tar.gz
CONTAINER=memos
CONTAINER_DATA_DIR=~/.../memos/data
# create backups directory if it does not exist
mkdir -p $BACKUP_DIR
# Stop the container
/usr/bin/docker stop $CONTAINER
# Backup the vaultwarden data directory to the backup directory
tar -czf "$BACKUP_DIR/$BACKUP_FILE" -C "$CONTAINER_DATA_DIR" .
# Restart the container
/usr/bin/docker restart $CONTAINER
# To delete files older than 30 days
find $BACKUP_DIR/* -mtime +30 -exec rm {} \;
Creating the cron job is also similar:
0 0 * * * .../memos/backup.sh
Since all the setups are quire simple and straightforward, memos fits my bill (thanks to the people) and I will spend some time to convert my notes soon.