Some tips/opinions about self-hosting
I've started self-hosting in 2012 because I wanted to put my own stuff on the internet without depending on some garbage-of-the-day gratis service and renting an extra machine (managed or not) didn't make sense, specially back when I was a minor.
Here is some tips/opinions about how to do it and avoid getting in the same issues as me and definitely others.
It doesn't matters if it's down for the others, make it for yourself first
I used to care more than I should about uptime, after all it's the most important thing when you host services, right? Well, no.
When self-hosting you should just prioritize having it as reachable and as reliable as you actually need. A human probably only has 60% of uptime, they sleep.
If you want something with more uptime see with friends with other sleep rythms, if you want something close to 99% of uptime you don't want self-hosting.
Put some redundancy on your disks; Automate the backups; prefer to edit locally and push
This is likely the most ignored thing ever in premade self-hosting setups I see around on the internet.
You need to mirror the disks holding data that you need constantly enough that you don't want to loose access to it for a long period of time (many hours, easily multiple days), typically that's the operating system and related software, the databases, the served data, … Typically you should use sofware raid solutions with reliability in mind like ZFS there.
You need to automate the backups, I tend to go with cron, shell scripts and rsync or tar and avoid turn-key solutions like borgbackup like the plague because of their lack of standardization/ubiquity, which helps for data recovery.
On that topic there there is two ways to do backups to another machine, pushing or pulling:
- pushing allows to avoid giving administation rights to the backup machine, which needs to be trusted but when this is done shouldn't be internet-facing;
- pulling allows to run everything with the least administration rights and can allow to use a less trusted machine, specially with using some encryption (be careful of the solution used there though, it needs to be reliable)
A very easy and efficient way to avoid having to do extra backups is to edit data locally under version control (ie. git) and push to the server for updates. This way you always have an extra copy and it allows to work offline.
Avoid SBCs (ie. RaspberryPi) and prefer PCs
Yet another thing where premade self-hosting setups tend to fail.
In their their generic sense, for example here a Sun Workstation or a Mac is a PC. PCs offers easy repairability and extensability. If I need more SATA ports or more USB ports on a PC without sacrifying speed I can put a PCI(e) card, the available boards also have much more ports to begin with. This also goes with the disk redundancy part, you'll want at least 2 large storage units
This also allows to boot on a standard operating system, so you don't need to grab an obscure operating system or one where you have to do compromises for installation or recovery, the usual ones just work. Which also means that you can swap-out the disks to a regular computer if some of your hosting hardware broke.
I think the best premade self-hosting machine would be something similar to a NAS where if it's non-x86 it should still have the ability to boot a generic image.
It's a private service in your own space, you don't have to let everyone in
One thing you might have to learn the hard way when providing services is saying no on giving power (admin, moderation) to some people, well it's like in politics, don't give power to the ones asking for it. Give them to the ones that aren't asking it and have no reason to not have it. Transparency and Honesty (even when blunt) are nice things to have, this avoids a lot of drama.
The internet and its crowd are chaos incarnate
Don't try to regulate everything that comes in, specially in terms of politics, behavior or moderations. Either you let no one but yourself write content (this is why my blog doesn't and never will have comments) or you have to let go of some space for the chaos to happen.
Moderating all the content which comes in is hard and a good example is spam in emails, there is always some nasty ones which manage to get in.
Chaos will always be there, acknowledge it's existance or be prepared for things to not go your way.