Skip to content
archive

GitHub Action

Mastodon Fossilize

v1 Latest version

Mastodon Fossilize

archive

Mastodon Fossilize

Mastodon account backup tool

Installation

Copy and paste the following snippet into your .yml file.

              

- name: Mastodon Fossilize

uses: potatoqualitee/fossilize@v1

Learn more about this action in potatoqualitee/fossilize

Choose a version

Fossilize - Mastodon account backup tool

This Action will help you backup Mastodon account items to CSV files, including:

  • Follows
  • Mutes
  • Account blocks
  • Lists
  • Bookmarks
  • Domain blocks
  • Followers
  • Posts

The export is performed using the Mastodon API and an Access Token.

Note that Followers and Posts cannot be imported using Mastodon's import web interface. Also, posts are exported in JSON format because they are more complex.

Documentation

Here's how you'd export your follows, lists, blocks, mutes, domain_blocks, bookmarks, followers, and posts if your account is on the dataplatform.social Mastodon instance. This will export the files to ./backups then attach a zip of the ./backups as an artifact to the workflow run.

- name: Backup account to files
  uses: potatoqualitee/fossilize@v1
    with:
        server: dataplatform.social
    env:
        ACCESS_TOKEN: "${{ secrets.ACCESS_TOKEN }}"

Note that Mastodon limits API calls to 300 per 5 minutes, which averages 1 second so each call will have a delay of one second, so that's why there seems to be a slight delay.

Usage

Pre-requisites

Get a Mastodon Bearer Token

A Mastodon token is required for this Action to work. Fortuantely, it's very easy to get one.

Go to your Mastodon profile/client/webpage and click Preferences -> Development -> New Application -> Application name: Whatever you like, I named mine Imports -> Limit Permissions (optional) -> Submit

Note

If you limit your permissions too much when you create the app, you may need to recreate it. I was too strict with my permissions and it looked like I could edit them but the edit is like a secondary scope

Click new application link -> Your access token

Add GitHub Secrets

Once you have your authentication information, you will need to them to your repository secrets.

I named my secret ACCESS_TOKEN. You can use any secretname you want, though you must ensure that your environmental variables are named appropriately, as seen in the sample code.

Create workflows

Finally, create a workflow .yml file in your repositories .github/workflows directory. An example workflow is available below. For more information, reference the GitHub Help Documentation for Creating a workflow file.

Inputs

  • server - Your Mastodon server. If you are [email protected], this would be dataplatform.social.
  • path - The path to the directory that will hold the CSV files, defaults to ./backups. This Action will create the directory if it does not exist.
  • type - Which items to backup. Options include: follows, lists, blocks, mutes, domain_blocks, bookmarks, followers, posts and all. Defaults to all.
  • auto-artifact - Attach the csv files as an artifact to this workflow. Default is true.
  • artifact-name - The name of the artifact. Default is mastodon-backup.
  • verbose - Show verbose output. Defaults to true.

Outputs

  • csv-path - The backup directory file path

Example workflows

Use the Fossilize action to backup your account to CSV each night at midnight and attach the zip as an artifact

name: Backup Mastodon Account
on:
  workflow_dispatch:
  schedule:
    - cron: "0 0 * * *"
jobs:
  backup:
    runs-on: ubuntu-latest
    steps:
      - name: Checkout the code
        uses: actions/checkout@v3

      - name: Backup Mastodon Account
        uses: potatoqualitee/fossilize@v1
        id: backup
        with:
          server: dataplatform.social
        env:
          ACCESS_TOKEN: "${{ secrets.ACCESS_TOKEN }}"

Details

Here's some extra examples for the inputs.

Input Example Another Example And Another
server dataplatform.social [email protected] https://dataplatform.social
path /tmp/backups ./backups

Want to run this locally?

Just add your $env:ACCESS_TOKEN environmental variables to your $profile and reload, clone the repo, change directories, modify this command and run.

./main.ps1 -Server yourinstance.tld -Path C:\temp\backups

Contributing

Pull requests are welcome!

You may also enjoy...

  • Mastodon Influx - This Action will help you import CSV files to Mastodon, including: Follows, Mutes, Account blocks, Lists, Bookmarks, and Domain blocks.
  • Twitter Exodus - This Action helps Twitter communities find members on Mastodon. Searches lists, hashtags, account followers and more for Mastodon links in their name, bio or pinned tweet. Once found, their info is exported to a CSV file that can be imported into Mastodon.
  • Using GitHub Pages to Setup an Alias on Mastodon - This tutorial can help you keep your social media presence without running your own Mastodon server.

TODO

You tell me! I'm open to suggestions. But also

  • Add more account compontents after I make a Mastodon module, then I can just export it from there

License

The scripts and documentation in this project are released under the MIT License