- backup
- truenas
- zfs
- ransomware
Turn your old server into the office backup system: TrueNAS and the 3-2-1 rule
A reliable backup system built from an idle office server or PC with free software: TrueNAS, ZFS snapshots, protection against ransomware, an off-site copy and restore tests.
Almost every office has an old server or a powerful PC standing in a corner: a new one was bought, the old one was kept "just in case". Yet in many of those same offices there is either no backup at all, or it sits on the second disk of that very server.
In this post we show how to turn that old server into a real, reliable backup system for the office. With free software and no extra licences.
Why "we have a backup" is often not true
The most common picture looks like this: the file server runs on drive D:, and at night a script copies the files to drive E:. On paper there is a backup. But it protects against none of these three cases:
- Ransomware. When encrypting malware lands on the server, it encrypts every disk it can see, drive E: included.
- The server itself fails. The motherboard, the RAID controller or the power supply dies, and both disks are stuck in the same box.
- Accidental deletion. An employee deletes a folder and someone notices a week later. By then the nightly script has already copied the deleted state into the backup.
A backup is only a backup if it cannot be destroyed together with the main system.
The 3-2-1 rule
A simple rule that has been used in this field for years:
- 3 copies: the primary data and two backups;
- on 2 different media: for example, the main server and a separate NAS;
- 1 copy off-site: so that a fire, a flood or a theft cannot take everything at once.
The old server takes care of the "2" part. We will come back to the "1" part at the end.
What you need
- An old server or PC. A 64-bit processor, at least 8 GB of RAM (16 GB or more is better, ZFS likes memory).
- A system disk. A small SSD is enough, 32–64 GB. TrueNAS is installed on this disk; no data is written to it.
- Data disks. At least two disks of the same size, so that if one fails the other keeps working.
- Important: the disks must not go through a hardware RAID controller. TrueNAS has to see the disks directly. If the server has a RAID controller, switch it to HBA mode (also called "IT mode" or "JBOD"), or connect the disks to the motherboard's SATA ports.
When choosing disks, avoid reusing the old disks from the old server. The backup disks should be the most reliable part of the system.
Step 1: install TrueNAS
TrueNAS is a free, open-source NAS operating system built on the ZFS file system. Download the ISO from the official website, write it to a USB stick and install it on the system disk. After installation the web interface opens at the server's IP address on the network, and everything else is managed from there.
Give the server a static IP and keep it on the office's internal network. Do not expose the NAS admin panel to the internet.
Step 2: the disk pool
Create a new pool in the Storage section:
- with 2 disks: Mirror. If one disk dies, no data is lost.
- with 4 or more disks: RAIDZ2. Even if two disks die at the same time, the data survives.
Inside the pool create a separate dataset for backups, for example backup. A separate dataset for each source (file server, 1C, accounting) makes management easier later.
Step 3: snapshots, the main weapon against ransomware
The strongest feature of ZFS is snapshots: an instant, read-only "photo" of a dataset at a given moment. A snapshot takes almost no space; space is used only for changes.
In Data Protection → Periodic Snapshot Tasks, set up a schedule such as:
- every hour, kept for 2 days;
- every day, kept for 30 days;
- every week, kept for 12 weeks.
The point is simple: even if ransomware encrypts the backup folder too, or someone deletes everything, you go back to yesterday's or last week's state in a few clicks. A user connected through a network share cannot delete snapshots.
One condition: the NAS admin password must not be the same as the Windows domain passwords and must not be stored on any work computer. If an attacker cannot get into the NAS itself, the snapshots stay untouched.
Step 4: getting data onto the NAS
File server (Windows). In TrueNAS, share the backup dataset over SMB and create a separate user just for backups (not the domain admin). On the Windows server, run this command every night with Task Scheduler:
robocopy "D:\Shares" "\\nas01\backup\fileserver" /MIR /Z /R:2 /W:5 /MT:8 /NP /LOG+:C:\Logs\backup.log/MIR also deletes from the copy the files that were deleted at the source. That sounds scary, but snapshots make it safe: a deleted file remains in the earlier snapshots.
1C. In the file version the database is a folder (1Cv8.1CD). Copying it while users are working can produce an incomplete copy. The most reliable way is to export the database to a .dt file with the Designer (at night, when nobody is working) and write that file to the NAS. In the server version (MS SQL or PostgreSQL), have the database's own backup written to the share on the NAS.
MS SQL Server. With a Maintenance Plan or an Agent job, write daily full backups and hourly log backups straight to the NAS share.
Step 5: the off-site copy, the "1" part
You now have two media, but both are in the same room. There are several ways to get an off-site copy:
- A second TrueNAS in another building (a branch, another office). TrueNAS Replication Tasks sends the snapshots there encrypted. Only changes are transferred, so the internet link is barely loaded.
- A copy in the cloud. Cloud Sync Tasks in TrueNAS supports encrypted uploads to S3-compatible storage services.
- A server in a local data centre. If it matters that the data stays in the country, you can replicate to a server in a data centre in Baku (we offer such servers at JezaHost too).
Whichever you choose, the off-site copy must be encrypted.
Step 6: test the restore
A backup that cannot be restored is not a backup. Run a small test once a month:
- restore a random file from a snapshot;
- open the 1C database on a test computer;
- restore the SQL backup to a test server.
Put it in the calendar. A problem should always be found before the day the backup is needed, not on that day.
Short checklist
- The backup is on a physical device separate from the main server.
- The NAS admin password is separate and not stored anywhere.
- A snapshot schedule is set up (hourly, daily, weekly).
- There is a separate user with limited rights for backups.
- There is an encrypted off-site copy.
- Restores are tested once a month.
- Alerts for the disks' health (SMART) are switched on.
If an old server is gathering dust in a box, give it one weekend. On the worst day, when all the company's data is encrypted or a disk dies, it will be the most valuable device in the office.