Skip to content

HasHooves/mastodon-backup

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

23 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Description Notes Author ProjectPage
Backup your essential Mastodon files to an S3 bucket!
This uses some simple scripts and cronjobs to create backups to a specified S3 bucket.
HasHooves

mastodon-backup

Backup your essential Mastodon files to an S3 bucket!

This set of scripts was created to automate some of the basic maintenance that I would normally use to cleanup and make backups of my mastodon instance.

Feel free to use this backup script to help keep your instance clean too!

Configure the AWS credentials

  • Install the AWS CLI
    • NOTE: This script requires that aws configure has already been completed for the root user before being ran for the first time

  • Fill out the example_config.sh file with your information for AWS, and then move it to config/config.sh

Prepare the script files

  • Set the two files as executable:
chmod +x backup.sh
chmod +x config/config.sh

Cronjobs

Setting up automated backups

  • Add this line to your root crontab to ensure that the backups are being ran daily and a log is being generated:
0 3 * * * /opt/mastodon-backup/backup.sh > /opt/mastodon-backup/logs/backup.log 2>&1

Weekly restart of server

  • Add this line to the root crontab to ensure that a weekly restart is occuring:
0 0 * * 0 /sbin/shutdown -r now

Automatic media cleanup

  • NOTE: This should be set for the mastodon account and not set as the root user

  • Add this line to the mastodon user's crontab to ensure that the media is being cleaned out daily and capped at 7 days:
@daily cd /home/mastodon/live && RAILS_ENV=production bin/tootctl media remove --days=7

Restart Cron

  • After making changes to crontab, restart the cron service:
sudo service cron restart

About

Backup your essential Mastodon files!

Topics

Resources

License

Code of conduct

Stars

Watchers

Forks

Sponsor this project

Packages

No packages published

Languages