Meta tags:
description= Copying your Mastodon installation to a new server without losing anything.;
Headings (most frequently used words):
migrating, to, steps, new, machine, basic, detailed, sponsored, by, stop, the, mastodon, services, what, data, needs, be, migrated, dump, and, load, postgresql, copy, files, certbot, during, migration, after,
Text of the page (most frequently used words):
the (73), mastodon (36), your (35), you (30), and (23), server (21), new (20), using (17), redis (16), run (14), this (13), for (13), copy (13), admin (13), user (12), can (11), database (11), production (10), #machine (10), system (10), with (8), systemctl (8), nginx (8), want (8), old (8), files (8), may (8), stop (8), dump (8), postgresql (8), file (7), live (7), config (7), letsencrypt (7), service (7), etc (6), rails_env (6), public (6), running (6), which (6), search (5), following (5), migrating (5), that (5), not (5), over (5), instance (5), also (4), dns (4), start (4), bin (4), tootctl (4), use (4), rebuild (4), take (4), time (4), root (4), will (4), directory (4), from (4), rsync (4), var (4), lib (4), contains (4), note (4), backup (4), pg_dump (4), steps (4), profile (4), account (4), api (4), oauth (4), available (3), own (3), point (3), elasticsearch (3), long (3), number (3), feeds (3), users (3), now (3), probably (3), set (3), migration (3), update (3), don (3), copying (3), systemd (3), pgbouncer (3), are (3), env (3), role (3), mastodon_production (3), password (3), load (3), under (3), what (3), data (3), services (3), guide (3), preferences (3), apps (3), reports (3), accounts (3), setting (3), source (2), improve (2), page (2), progress (2), process (2), edit (2), playing (2), deploy (2), indices (2), depending (2), statuses (2), build (2), once (2), home (2), sidekiq (2), streaming (2), commands (2), bundle (2), exec (2), rails (2), assets (2), precompile (2), after (2), error (2), during (2), instead (2), certificate (2), when (2), just (2), any (2), overwrite (2), sites (2), certbot (2), avz (2), example (2), com (2), cli (2), save (2), restore (2), should (2), secrets (2), change (2), some (2), username (2), pg_restore (2), then (2), performance (2), template0 (2), create (2), empty (2), postgres (2), convenience (2), restoring (2), documentation (2), setup (2), both (2), configuration (2), need (2), needs (2), migrated (2), detailed (2), settings (2), skip (2), step (2), timelines (2), instructions (2), below (2), basic (2), other (2), notificationpolicy (2), filter (2), report (2), quote (2), domainblock (2), notifications (2), trends (2), collections (2), domain_blocks (2), tokens (2), security (2), environment (2), implementing (2), posts (2), installing (2), features (2), configuring (2), imprint, view, blog, join, sponsored, last, updated, november, 2025, 简体中文, check, see, propagation, jumpstart, always, around, early, hosts, whatsmydns, net, command, have, back, online, restart, enable, web, daemon, reload, ttl, something, small, minutes, about, day, advance, propagate, quickly, address, show, nice, message, let, existing, know, 500, html, referenced, path, folder, else, complain, try, generate, temporary, since, anyway, ssl_certificate_key, ssl_certificate, sufficient, optionally, rewrite, them, scratch, adjust, location, needed, ensure, otherwise, trying, avoid, unnecessarily, recommended, values, above, okay, different, between, two, servers, owner, import, replace, cpus, createdb, scp, alter, your_password, sudo, psql, configure, same, going, useful, described, before, hours, 15gb, dumping, temporarily, tune, contain, tweaks, customizations, ssl, certificates, domain, less, crucially, unprocessed, jobs, uploaded, images, videos, high, level, enjoy, necessary, each, compile, machines, however, only, leave, was, written, ubuntu, mind, mileage, vary, setups, sometimes, various, reasons, migrate, one, another, fortunately, too, difficult, although, result, downtime, installation, without, losing, anything, webpushsubscription, translation, token, termsofservice, tag, suggestion, statussource, statusedit, status, shallowtag, shallowquote, scheduledstatus, rule, relationshipseveranceevent, relationship, reaction, quoteapproval, privacypolicy, previewcardauthor, previewcard, poll, notificationrequest, notificationfallback, notification, mediaattachment, marker, list, identityproof, filterstatus, filterresult, filterkeyword, featuredtag, featureapproval, familiarfollowers, extendeddescription, customemoji, conversation, context, collectionwithaccounts, collectionitem, collection, asyncrefresh, application, appeal, annualreport, announcement, measure, ipblock, emaildomainblock, domainallow, dimension, cohort, canonicalemailblock, accountwarning, entities, markers, lists, conversations, scheduled_statuses, polls, media, proofs, oembed, push, custom_emojis, announcements, health, grouped, async_refreshes, emails, annual, retention, measures, ip_blocks, email_domain_blocks, domain_allows, dimensions, canonical_email_blocks, tags, suggestions, mutes, followed_tags, follow_requests, filters, featured_tags, favourites, endorsements, bookmarks, blocks, methods, rate, limits, scopes, guidelines, best, practices, datetime, formats, rest, bearcaps, microformats, webfinger, activitypub, spec, compliance, design, reference, creating, themes, css, styling, state, management, components, frontend, issues, responsible, disclosure, routes, code, structure, dev, technical, overview, contributing, libraries, implementations, logging, obtaining, client, app, access, getting, started, developing, roles, webhooks, index, corruption, troubleshooting, errors, moderation, actions, scaling, backing, upgrading, release, single, sign, captcha, onion, object, storage, optional, full, text, preparing, official, ios, android, moving, leaving, externally, more, promoting, yourself, others, dealing, unwanted, content, quoting, network, posting, signing,
Text of the page (random words):
migrating to a new machine mastodon documentation what is mastodon using mastodon signing up for an account setting up your profile posting to your profile using the network features quoting other posts dealing with unwanted content promoting yourself and others set your preferences more settings using mastodon externally moving or leaving accounts official ios and android apps running your own server running mastodon preparing your machine installing from source configuring your environment configuring full text search installing optional features object storage onion services captcha single sign on setting up your new instance using the admin cli upgrading to a new release backing up your server migrating to a new machine scaling up your server moderation actions troubleshooting errors database index corruption webhooks roles developing mastodon apps getting started with the api playing with public data obtaining client app access logging in with an account libraries and implementations implementing quote posts implementing collections contributing to mastodon technical overview setting up a dev environment code structure routes security issues and responsible disclosure frontend guide components state management css and styling creating themes design tokens reference spec compliance activitypub webfinger security microformats oauth bearcaps rest api datetime formats guidelines and best practices oauth tokens oauth scopes rate limits api methods accounts blocks bookmarks domain_blocks endorsements favourites featured_tags filters follow_requests followed_tags mutes preferences reports suggestions tags admin accounts canonical_email_blocks dimensions domain_allows domain_blocks email_domain_blocks ip_blocks measures reports retention trends annual reports apps emails oauth async_refreshes collections grouped notifications health instance announcements custom_emojis directory trends notifications push oembed profile proofs search statuses media polls scheduled_statuses timelines conversations lists markers streaming api entities account accountwarning admin account admin canonicalemailblock admin cohort admin dimension admin domainallow admin domainblock admin emaildomainblock admin ip admin ipblock admin measure admin report announcement annualreport appeal application asyncrefresh collection collectionitem collectionwithaccounts context conversation customemoji domainblock error extendeddescription familiarfollowers featureapproval featuredtag filter filterkeyword filterresult filterstatus identityproof instance list marker mediaattachment notification notificationfallback notificationpolicy notificationrequest poll preferences previewcard previewcardauthor privacypolicy profile quote quoteapproval reaction relationship relationshipseveranceevent report role rule scheduledstatus search shallowquote shallowtag status statusedit statussource suggestion tag termsofservice token translation v1 filter v1 instance v1 notificationpolicy webpushsubscription migrating to a new machine copying your mastodon installation to a new server without losing anything basic steps detailed steps stop the mastodon services what data needs to be migrated dump and load postgresql copy files certbot during migration after migrating 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 this guide was written with ubuntu server in mind your mileage may vary for other setups basic steps set up a new mastodon server using the production guide however don t run mastodon setup and only leave the postgresql service running stop mastodon on the old server e g systemctl stop mastodon service dump and load the postgresql database using the instructions below copy the system files using the instructions below note if you re using s3 you can skip this step copy the env production file save the redis database stop the redis service on both your old and new machines and copy the redis database from var lib redis to the new server run rails_env production bundle exec rails assets precompile to compile mastodon start mastodon and redis on the new server run rails_env production bin tootctl feeds build to rebuild the home timelines for each user run rails_env production bin tootctl search deploy to rebuild your elasticsearch indices note if you are not using elasticsearch you can skip this step update your dns settings to point to the new server update or copy your nginx configuration and re run letsencrypt as necessary enjoy your new server detailed steps stop the mastodon services systemctl stop mastodon service what data needs to be migrated at a high level you ll need to copy over the following the live public system directory which contains user uploaded images and videos if using s3 you don t need this the postgresql database using pg_dump the live env production file which contains server config and secrets the redis database in the var lib redis directory which contains unprocessed sidekiq jobs less crucially you ll probably also want to copy the following for convenience the nginx config under etc nginx sites available mastodon the ssl certificates for your domain under etc letsencrypt live if using letsencrypt 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 dump and load postgresql before you start note that both pg_dump and pg_restore can take a long time as in hours for a 15gb backup file you may want to temporarily tune postgres s performance just for dumping restoring instead of running mastodon setup we re going to create an empty postgresql database using the template0 database which is useful when restoring a postgresql dump as described in the pg_dump documentation if you are using a password for your postgresql user you may want to configure the mastodon user on your new system to use the same password as your old system for convenience sudo u postgres psql alter user mastodon with password your_password q run this as the mastodon user on your old system pg_dump fc mastodon_production f backup dump copy the backup dump file over using rsync or scp then on the new system create an empty database as the mastodon user createdb t template0 mastodon_production then import it replace in j with the number of cpus in your system to improve restore performance pg_restore fc j u mastodon n public no owner role mastodon d mastodon_production backup dump note that if the username is not mastodon on the new server you should change the u and role values above it s okay if the username is different between the two servers copy files this will probably take some time and you ll want to avoid re copying unnecessarily so using rsync is recommended on your old machine as the mastodon user run rsync avz live public system mastodon example com live public system you ll want to re run this if any of the files on the old server change you should also copy over the env production file which contains secrets on your new machine ensure that redis is not running otherwise it may overwrite the dump file you are trying to restore as the root user run systemctl stop redis server service now copy your redis database over adjust the location of your redis database as needed on your old machine as the root user run redis cli save systemctl stop redis server service rsync avz var lib redis root example com var lib redis optionally you may copy over the nginx systemd and pgbouncer config files or rewrite them from scratch certbot copying your nginx config files will not be sufficient to re run letsencrypt instead copy the certificate files referenced by ssl_certificate and ssl_certificate_key in etc nginx sites available mastodon to the new machine and update the path in the new machine s nginx config don t use letsencrypt s own live folder for this or else letsencrypt will complain when you try to re generate the certificate just use any temporary directory for this since re running letsencrypt will overwrite the config anyway during migration you can edit the live public 500 html page on the old machine if you want to show a nice error message to let existing users know that a migration is in progress you ll probably also want to set the dns ttl to something small 30 60 minutes about a day in advance so that dns can propagate quickly once you point it to the new ip address after migrating run the following commands as your mastodon user rails_env production bundle exec rails assets precompile now run the following commands as your root user systemctl daemon reload systemctl start redis server systemctl enable now mastodon web mastodon sidekiq mastodon streaming systemctl restart nginx once your server is back online you can rebuild the home feeds for users this can take a long time depending on the number of users rails_env production bin tootctl feeds build if you use elasticsearch run the following command to rebuild the indices this can take a long time depending on the number of statuses you have rails_env production bin tootctl search deploy you can check whatsmydns net to see the progress of dns propagation to jumpstart the process you can always edit your own etc hosts file to point to your new server so you can start playing around with it early last updated november 27 2025 improve this page also available in 简体中文 sponsored by join mastodon blog view source cc by sa 4 0 imprint
|