I’ve been running a homelab for some time now, with both successes and many failures But it’s a lot of fun, so I’m not thinking about quitting anytime soon.
One of the most important things for me is not losing data, especially not my own. Because of that, I’m planning to use rsync to backup data to an external USB drive with an NTFS partition connected to my server.
The main goal is to backup my wife’s data so she can easily access her files if everything stops working. She mostly uses Windows, so it’s important that the backup drive uses NTFS. I want to avoid a situation where she plugs the drive into a Windows computer and sees the message:
“You need to format the disk before you can use it. Do you want to format it?”
I’m planning to use Jay’s backup script template from the guide “How to Automate Linux Backups Using rsync and systemd.”
My question is, should I add anything else to the template, such as running “sync” at the end, to avoid unexpected problems?
I’d really appreciate any help or suggestions
Template:
#!/bin/bash
backup_src="/home/jay/my_files"
backup_mount="/mnt/backup"
backup_dest="$backup_mount/current"
current_date=$(date +%Y-%m-%d)
log_path="$backup_mount/logs"
previous_files="$backup_mount/files_previous/$current_date"
healthcheck_url="https://hc-ping.com/..."
# Create required directories
#mkdir -p "$log_path"
#mkdir -p "$previous_files"
# Run rsync
#rsync -av --delete --backup \
# --backup-dir="$previous_files" "$backup_src" "$backup_dest" \
# > "$log_path/backup_$current_date.log" \
# 2> "$log_path/backup_${current_date}_error.log"
echo "test"
# Alert halthchecks.io that rsync was successful:
if [ $? -eq 0 ]; then
curl -fsS "$healthcheck_url" >/dev/null
fi
afaik nfs needs to be added manually in (almost?) any Linux distribution since it’s not shipped by default. So, it is unlikely that TrueNAS can mount nfs. You could format your drive as exFAT since this should be readable natively on both systems and even MacOS.
I’m a little worried about exFAT because it does not have journaling. It’s important that the data on this drive stays reliable. I expect that, in the worst case, she will unplug the external drive, connect it to her computer, and start using it. She probably will not want to deal with file systems or technical details.
Now I’m thinking about another option: mount an NTFS drive on a different system, share it using SMB, then mount it in TrueNAS and set up the backup there. What do you think about this idea?
It’s not ideal, but I found a workaround by mounting SMB with Init/Shutdown Scripts. It’s not pretty, but it works.
She used to work that way for years, but when she saw that I could access all my data remotely from any device, she wanted the same. I don’t want to take away her ability to access her data remotely from both her phone and computer.
I should mention that we are using Nextcloud. My setup is like this:
All data is stored in TrueNAS datasets.
Nextcloud runs in a Docker container on TrueNAS.
TrueNAS datasets are mounted as External Storage in Nextcloud.
Everything is working great. The only thing missing right now is an emergency backup of my wife’s data to an external NTFS drive. I plan to write instructions, print them, and attach them to the enclosure so she knows what to do.
Do you think the approach of mounting an NTFS drive on a different system, sharing it via SMB, then mounting it in TrueNAS with Init/Shutdown Scripts and setting up the backup there is a good way to go?
Thank you for confirming that the NTFS partition can be mounted in TrueNAS. I will check it myself later this week. Assuming it can be mounted, your rsync command is:
Is this enough to prevent a situation where the drive, when connected to a Windows computer, shows the message “You need to format the disk before you can use it. Do you want to format it?”
Do I need to run sync at the end, or anything else?
The USB Drive need to be NTFS formatted ahead, and beause you mount it with type ntfs nothing changes on the Filesystem Format so nothing Windows can complain about.
sync is optional ( flush write cache) but good, and umount is required before unplugging.
One last Note: if you sync from Linux there is no need to add --exclude=‘System Volume Information/’ --exclude=‘$RECYCLE.BIN/’
rsync to ntfs will probably strip relevant metadata. The linux NTFS driver for instance won’t know what to do to properly store MacOS color tags for instance or MacOS resource forks. These are stored on ZFS filesystem as user namespace xattrs, but they should be stored as alternate data streams on NTFS… only one example, but there’s a reason why we don’t present it as a viable backup option in the UI. It works okay until somone loses something they consider vital.
Thank you for pointing that out. We are not using macOS tags. Data access is only through SMB and Nextcloud, where I enable “Enforce Windows compatibility.” TrueNAS datasets mapped to Nextcloud are also case-insensitive.
What else can I do to prevent data loss? It’s very important to me not to limit her ability to access her data remotely, while also having an emergency backup of all her data on an NTFS drive.
What systems do you have available to attach the USB / NTFS drive to? If there is a Windows desktop you could always look at mapping a drive letter to the SMB share source on TrueNAS and then just set up a ROBOCOPY script on the Windows machine to copy the data from the TrueNAS SMB share to the external USB drive. You could set it on a schedule and control file type exclusions, whether it is deleteing files or just copying. I use ROBOCOPY in Powershell on Windows 11 to sync my data to my TrueNAS SMB share, as a backup. I run it manually, but you should be able to make a script and set it to run scheduled on Windows.
I don’t have a Windows system available right now. In my previous post, I wrote about connecting an NTFS drive to another system, sharing it using SMB, and then mounting it in TrueNAS. I was actually thinking about connecting the drive to my Fritzbox 4060 router instead of a Windows computer. Unfortunately, this would not work with Robocopy
If I cannot use rsync from TrueNAS (which I strongly prefer), I could buy a low-power mini PC and set it up as you suggested. However, I would prefer to use the hardware I already have instead of buying new devices.
If there is no other option, I will buy new hardware, because having an uncorrupted backup is the most important thing. But maybe… just maybe… there is still a way to do this without buying anything new.
I like the idea that @MRi suggested, but after @awalkerix pointed out some drawbacks, I’m not sure anymore.
Is it still a bad idea, even if we use options like --no-perms --no-owner --no-group --no-acls --no-xattrs, which we don’t really need?