Is there easy way to backup and restore like wordpress way?
For anyone not familiar with wordpress:
export file to xml from admin panel
backup one folder
install new version of wordpress
import xml file
copy one folder
this is very convenient to use new install and clean without any leftovers
Any assistance with this one?
I’m unable to run any clean up commands due to very low disk space so would like to start a new one and just copy over required items only.
this will be different depending on whether you’re using docker or not. are you?
You can get a backup of the database with the pg_dump program. The actual command you’ll run will depend on what name you used for your database; I run
pg_dump mastodon_production > /home/mastodon/backup.psqld
Then you can FTP the backup and your .env_production file to a different server, clear the disk, create the new database, and
then restore with psql:
psql mastodon_production < backup.psqld
(This doesn’t create the database on its own; you’ll have to create it yourself first before running the psql import.)
Possibly this isn’t quite what you’re asking, but I figured it might be useful.
@beatrix-bitrot I am not using docker installation
@noelle does that mean that I can follow the production installation guide then just restore the database and everything will be back to normal? Does the database backup also include local user avatar and attachment?
the database contains all the necessary references to the avatars and attachments but the files themselves are stored either in S3 or in the ‘public’ directory somewhere
if they’re in S3 you don’t need to do anything
if they’re in ‘public’ you should move them to the new place
Unless someone beats me to it, I’ll try to spend some time this weekend coming up with a script that’ll put the database backup, .env_production, and the avatars and media into a tarball for easy extraction. (Warning: this is likely to be huge if your instance is more than a few users.)
maybe instead of tarball (because if space is low there will be no room for it?) script can scp or rsync the necessary stuff directly to destination?
fuckin’ good on ya tho
I’d say even the script that just make a pg_dump and then prepares a list of file to be dumped would be a huge win. One could then just ./script | pax -w to tar them or rsync or whatever.
Fair cops. I’ll see what I can put together.
apparently i’m not allowed to post anything under 20 characters so this is filling space
just wanted to say
noelle, you’re great
@noelle I’ve created a backup script. It has to be run by the mastodon user:
echo -e "Mastodon backup:\n-------------"
echo -e "\n creating database dump"
pg_dump mastodon_production | gzip -9 > "$dbdump" || exit $?
echo -e "creating content archive"
tar cf - /home/mastodon/live/public/system | gzip -9 > "$content" || exit $?
echo -e "creating config archive"
tar cf - /home/mastodon/live/.env.production | gzip -9 > "$config" || exit $?
# END #
Do you have comments or criticism?
This is probably a good reference to achieve the backup and restore of a Mastodon instance.
This file has been truncated.
Sometimes, for various reasons, you may want to migrate your Mastodon instance from one server to another. Fortunately this is not too difficult of a process, although it may result in some downtime.
**Note:** this guide was written with Ubuntu Server 16.04 in mind; your mileage may vary for other setups.
1. Set up a new Mastodon server using the [Production Guide](https://github.com/tootsuite/documentation/blob/master/Running-Mastodon/Production-guide.md) (however, don't run `db:setup`).
2. Stop Mastodon on the old server (e.g. `systemctl stop 'mastodon-*.service'`).
3. Dump and load the Postgres database using the instructions below.
4. Copy the `system/` files using the instructions below.
5. Run `RAILS_ENV=production bundle exec rails mastodon:feeds:build` to rebuild the home timelines for each user.
6. Start Mastodon on the new server.
7. Update your DNS settings to point to the new server.
8. Update or copy your Nginx configuration, re-run LetsEncrypt as necessary.
9. Enjoy your new server!
@eruizdechavez You are right. But they’ve been talking about a script for regular backups. I just wanted to share my script with everyone.
@scroom makes sense!
I didn’t take the time to read your message before but now that I did I see it is doing almost exactly what the migration guide explains. I would probably just add an optional section to cover these:
Less crucially, you’ll proably also want to copy the following for convenience:
The nginx config (under /etc/nginx/sites-available/default)
The systemd config files (/etc/systemd/system/mastodon-*.service), which may contain your server tweaks and customizations
The pgbouncer configuration under /etc/pgbouncer (if you’re using it)
I would probably backup all Let’s Encrypt certificates but those require sudo privileges, but I am not sure if those require backup or if you can just regenerate new certs.
Hi all. I’ve started a simple project called
incognitum which completely autonomously manages nightly encrypted offsite backups for Mastodon [Docker/Non-Docker].
I’ve posted further details here:
Are server backups and snapshots good enough to backup an instance?