You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
Zlatko Đurić 36637f9943 fixup much of the tests 2 years ago
src fixup much of the tests 2 years ago
.gitignore Aparently functioning backup 2 years ago
.npmrc add the npmrc config 2 years ago
CHANGELOG.md information update 2 years ago
LICENSE Initial commit 2 years ago
README.md Rename the utility and reorganize into commands 2 years ago
package-lock.json fixup much of the tests 2 years ago
package.json fixup much of the tests 2 years ago

README.md

gts-utils

Utilities for running my own gotosocial instance.

Warning: It says above, "for running my own instance" for a reason. The utils are untested, untried (apart from my own tests), highly unstable and experimental. When the software matures, I'll remove the above warning.

gts-backup

Description

This project is created to help me backup my gotosocial instance. The official docs offer a few ways, but they don't work for me.

I want to do a following backup:

  • make sure my database (sqlite, yay simple stuff!) is backed up
  • make sure all the media that I have produced is backed up.

The alternatives proposed in the docs don't work for me:

  • I don't wanna clone my volume - it costs too much since I have more then just GTS there.
  • I don't wanna copy just my database because I want to keep my media that I posted.
  • I don't want to use the CLI since I also want to keep my statuses.

So I had to write my own thing.

Copying the database is easy, but which media to back up? That's what my tool is doing.

Usage

Installation

# Install this globally, then call it:
npm install -g @zladuric/gts-utils
# Alternatively npx it without installation:
npx -p @zladuric/gts-utils ...

Usage

gts-utils backup --username zlatko --src /mnt/data --dest /mnt/backups/gts-backup
gts-utils backup --username zlatko --src /mnt/data --db /mnt/gts/sqlite-other-version.db --dest /tmp/gts-backup

When you're done, just backup the top-level directory

To use this backup tool, I use a very simple filtering system: my username. I just select all media created by my account (originals and thumbnails) and copy that out there somewhere. In theory, you can just run it multiple times for multiple usernames, if you have them, but I haven't tested that.

Options:

  • username: a username to backup
  • src: where the media volume (data in your gts) is
  • db: location of the sqlite database (if not in the root of the data directory)
  • dest: the destination

Usage in your projects

So far this seems to highly experimentally und not at all safely also work if you just require the src/program.js:


[zlatko@serenity ~/projects/gts-utils]$ node
Welcome to Node.js v18.12.1.
Type ".help" for more information.
> const run = require('./src/program');
undefined
> run({ src: 'data/src', dest: 'data/dest', username: 'zlatko'});
Backing up gotosocial media. Check directory and database accesses...
Opening database...
Get the files to back  up...
select file_path,thumbnail_path from media_attachments join accounts on accounts.id = media_attachments.account_id where account_id in (select id from accounts where username like '%zlatko%')
Got the files needed for backup: 40 
Copying media...
Media copied, copying database...
Backup complete. Now tar it somewhere safe.
undefined
> 

But beware - if a file is missing or something is wrong, we call process.exit(1) explicitly.