Iāve been running NCP for years on a Pi 3 booting from a flash drive containing the system and with my data drive on a HDD formatted as ext4. Iāve been automaticity generating dataless backups (with occasional manual full backups). However Iām finally looking at using BTRFS so I can backup with snapshots.
Is the process āsimplyā to format a new HDD as BTRFS, connect the new HDD to the NCP system, copy all the data from the original disk across then switch the mount point to use the new drive?
Assuming this is correct and works my next steps will be to reformat the existing HDD as BTRFS and create snapshots to this, and eventually to copy these snapshots to an additional BTRFS share on an Unraid server. But Iām initially just wanting to get the data drive set up as BTRFS.
Sounds good (ā¦but āTs and Cs applyā). Why BTRFS, though?
more
Disclaimer: I havenāt used BTRFS for a few years; see belowā¦
Using snapshots is a good idea, because it helps reduce the possibility that your backups will be internally inconsistent But remember that for a complete backup of your data, youāll also need a (contemporaneous) dump of the database (i.e. in addition to the file system).
The way I do this is:
Put my Nextcloud instance into Maintenance Mode
Dump out the DB
Take a snapshot of the filesystem where Nextcloud data live
Take my instance out of Maintenance Mode again
Create the backup from the DB dump and the 'shot
ā¦which means Nextcloud is only offline - in Maintenance Mode - very briefly. (This is run by a systemd .service file and .timer file).
At the risk of stating the obvious: if youāre going to transfer your data from their current home to a new disk, you should do it when those data are offline (ā¦so youāre not trying to copy āa moving targetā).
EDIT Re āofflineā -
To be clear, what I mean is: 1. Stop Nextcloud entirely (i.e. stop Apache/Nginx/whatever) 2. Re-mount the existing data disk read-only 3. Copy the data from there to the new disk.
Qs.
AAMOI, why BTRFS? Once upon a time it was quite popular, I thinkā¦but nowadays it seems to have been eclipsed by ZFS(?) which is what I use. And if all you need is snapshots, you donāt need either of them: LVM can do that
How comparable are the two data disks, and could you use both at once? Is it worth combining them somehow (RAID1 via mdadm, or LVM, or ZFS, or whatever) for redundancyā¦?
Yes, your approach is basically what I was envisioning, thanks for confirming I am on the right path
As to why BTRFSā¦ I donāt really know much anything about filesystems, but my belief was that ZFS is more complicated that BTRFS, and more designed for pools of multiple drives. This is just for a single drive home Nextcloud server with a couple of users.
Thanks for mentioning LVM, I shall investigate that, but again this is just for a small server running on a Pi, so Iām happy to keep everything as simple as possible. Every new thing I try is an opportunity to break something due to my lack of knowledge
Indeed just occasionally copying the exported full backup to the second drive would probably be enough, but since the data will not change much, if I am understanding it correctly, after the initial snapshot the later ones will be smaller, just containing the delta of the changes, rather than a full export of the data folder.
Thatās probably true. Though as I say, I havenāt used BTRFS for a while; my memory may be rusty! I know ZFS fairly well, and it does lots of cool stuff. But itās not the best choice for everything, I think.
If you donāt need all the fancy new-fangled features of BTRFS and ZFS, my suggestion would be to stick with good old ext4. But put it in a Logical Volume, so you can snapshot it.
Indeed just occasionally copying the exported full backup to the second drive would probably be enough, but since the data will not change much, if I am understanding it correctly, after the initial snapshot the later ones will be smaller, just containing the delta of the changes, rather than a full export of the data folder.
Taking a snapshot of the file system with the āliveā data folder, then rsyncāing that to the other disk, you mean? Yep, that sounds good I recommend automating this as much as possible (with systemd or cron); personally, Iām very good at forgetting to do this kind of thing (unfortunately)ā¦
Do check out borg, though; itās really good. (Or restic, which is sort-of comparable).