Skip to content

Instantly share code, notes, and snippets.

@learosema
Last active October 14, 2023 10:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save learosema/7ce2d8a6b44bb500ecada80907422cbf to your computer and use it in GitHub Desktop.
Save learosema/7ce2d8a6b44bb500ecada80907422cbf to your computer and use it in GitHub Desktop.
leas mastodon recovery notes

Running db backups and or tootctl commands from chroot environment

Wow my server is completely fucked up right now. All I can do is try to create a backup from the most recent data dir... something with dbus daemon prevents from logging me in and it makes everything slow.

# Create mount bindings
mount --bind /dev /repair/dev
mount --bind /dev/shm /repair/dev/shm
mount --bind /dev/pts /repair/dev/pts
mount --bind /proc /repair/proc
mount --bind /sys /repair/sys
mount --bind /tmp /repair/tmp


# chroot into environment
chroot /repair
export LC_ALL=C

# change config file postgresql, reduce shared_buffers
nano -w /etc/postgresql/15/main/postgresql.conf

# start postgresql and redis
/etc/init.d/postgresql start
/etc/init.d/redis-server start

su - mastodon
# now you should be able to run tootctl commands.

Screen Microtutorial

For long-running processes, it's better to use screen, so you can detach them from the current SSH session:

screen -S backups

Instead of backups you can use an arbitrary name.

In order to detach from a session, press Ctrl + A D. Detaching from a session won't quit the running process. There is also a help via Ctrl + A ?

To list the sessions, there is screen -ls. To reattach to a session, use screen -r.

If there is more than one session, you have to provide a session id number (look up via -ls).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment