this post was submitted on 15 Oct 2024
179 points (100.0% liked)

Linux

48185 readers
1238 users here now

From Wikipedia, the free encyclopedia

Linux is a family of open source Unix-like operating systems based on the Linux kernel, an operating system kernel first released on September 17, 1991 by Linus Torvalds. Linux is typically packaged in a Linux distribution (or distro for short).

Distributions include the Linux kernel and supporting system software and libraries, many of which are provided by the GNU Project. Many Linux distributions use the word "Linux" in their name, but the Free Software Foundation uses the name GNU/Linux to emphasize the importance of GNU software, causing some controversy.

Rules

Related Communities

Community icon by Alpár-Etele Méder, licensed under CC BY 3.0

founded 5 years ago
MODERATORS
 

Can you please share your backup strategies for linux? I'm curious to know what tools you use and why?How do you automate/schedule backups? Which files/folders you back up? What is your prefered hardware/cloud storage and how do you manage storage space?

top 50 comments
sorted by: hot top controversial new old
[–] [email protected] 1 points 4 weeks ago* (last edited 4 weeks ago)

I built a backup server out of my old desktop, running Ubuntu and ZFS

I have a dataset for each of my computers and i back them up to the corresponding datasets in the zfs pool on the server semi-regularly. The zfs pool has enough disks for some redundancy, so i can handle occasional drive failures. My other computers run arbitrary filesystems (ext4, btrfs, rarely ntfs)

the only problem with my current setup is that if there is file degradation on my workstation that i dont notice, it might get backed up to the server by mistake. then a degraded file might overwrite a non-degraded backup. to avoid this, i generally dont overwrite files when i backup. since 90% of my data is pictures, it's not a big deal since they dont change

Someday i'd like to set up proxmox and virtualize everything, and i'd also like to set up something offsite i could zfs-send to as a second backup

[–] [email protected] 3 points 1 month ago

Main drive is a 1 1TB super fast m.2 device, backup drive is an 8TB platter drive with btrfs.

Bunch of scripts I wrote myself copy all important stuff to the platter drive every night using rsync, then makes a snapshot with current date. Since its all copy on write, i have daily backups for like 3 years now. Some extra scripts clean up some of the older backups, lowering the backup frequency to once a week after a year, once every 4 weeks after 2 years.

I have similar solutions for my servers where i rsync the backups over the Internet.

[–] [email protected] 5 points 1 month ago

I have a synology NAS with all my documents and family photos. I'm using the synology drive app on Linux and synology photo on android.

All of that is backed up on Backblaze

[–] [email protected] 10 points 1 month ago

Shout out to all the homies with nothing, I'm still waiting to buy a larger disk in hopes of rescuing as much data from a failing 3TB disk as I can. I got some read errors and unplugged it about 3 months ago.

[–] [email protected] 5 points 1 month ago

Me n' Backup don't go in the same sentence...it's all "Restore" fault

[–] [email protected] 3 points 1 month ago (2 children)

I use OneDrive. I know people will hate but it’s cheap and works on everything (well, it takes a third party tool on Linux). If I care about it it goes in OneDrive, otherwise I don’t need it that much.

[–] [email protected] 1 points 1 month ago

may I ask which third-party tool you use? i'm using onedriver and it's pretty unreliable in my experience

[–] [email protected] 2 points 1 month ago

May I ask why you prefer that over Google Drive, or others such as Dropbox or Mega? I used it extensively when I used Windows, but that's been several years.

[–] [email protected] 4 points 1 month ago

Dot files on github, an HHD for storing photos, downloads, documents as well as my not in use games. I also sync keepass files across all network devices.

[–] [email protected] 10 points 1 month ago* (last edited 1 month ago)

I was talking with a techhead from the 80s about what he did when his tape drives failed and the folly that is keeping data alive on a system that doesn't need to be. His foolproof backup storage is as follows.

  1. At Christmas buy a new hard drive. If Moore's law allows, it should be double what you currently have
  2. Put your current backup hardrive into a SATA drive slot. Copy over backup into new hard drive.
  3. Write with a sharpie the date at which this was done on the harddrive. The new hard drive is your current backup.
  4. Place the now old backup into your drawer and forget about it.
  5. On New Years Day, load each of the drives into a SATA drive slot and fix any filesystem issues.
  6. Put them back into the drawer. Go to step 1.
[–] [email protected] 6 points 1 month ago

One reason for moving to Nix was declarative config so at least that part of my system is a series of Nix files to build into a working setup.

…The rest… let’s just say “needs improvement” & I would like to set up a NAS.

[–] [email protected] 6 points 1 month ago (1 children)

I'm using rustic, a lock-free rust-written drop-in-replacement of restic, which (I'm referring to restic and therefore in extension to rustic) supports always-encrypted, deduplicating, compressed and easy backups without you needing to worry about whether to do a full- or incremental-backup.

All my machines run hourly backups of all mounted partitions to an append-only repo at borgbase. I have a file with ignore pattern globs to skip unwanted files and dirs (i.e.: **/.cache).

While I think borgbase is ok, ther're just using hetzner storage boxes in the background, which are cheaper if you use them directly. I'm thinking of migrating my backups to a handfull of homelabs from trusted friends and family instead.

The backups have a randomized delay of 5m and typically take about 8-9s each (unless big new files need to be uploaded). They are triggered by persistent systemd-timers.

The backups have been running across my laptop, pc and server for about 6 months now and I'm at ~380 GiB storage usage total.

I've mounted backup snapshots on multiple occasions already to either get an old version of a file, or restore it entirely.

There is a tool called redu which is like ncdu but works on restic/rustic repos. This makes it easy to identify which files blow up your backup size.

[–] [email protected] 2 points 1 month ago

This is the correct way. I wish hetzner had a storage box size between the 1TB and 5TB version though.

[–] [email protected] 10 points 1 month ago (1 children)
[–] [email protected] 6 points 1 month ago

I too am raw-dogging my Linux install

[–] [email protected] 4 points 1 month ago* (last edited 1 month ago) (1 children)
  1. Work in a cloud-synced folder by default.

That's all my step 🦥

[–] [email protected] 1 points 1 month ago (1 children)

Same, but with rsync.
I'm just not competent.

[–] [email protected] 2 points 1 month ago
[–] [email protected] 9 points 1 month ago (1 children)

Dump configs to backup drive. Pray to the machine spirit that things don't blow up. Only update when I remember. I'm a terrible admin for my own stuff.

[–] [email protected] 3 points 1 month ago

Thanks to you, I don't need to answer to OP anymore👍

[–] [email protected] 3 points 1 month ago

Bareos. Its a newer Form of bacula and is a realworkhorse.

[–] [email protected] 6 points 1 month ago

Example of a Bash script that performs the following tasks

  1. Checks the availability of an important web server.
  2. Checks disk space usage.
  3. Makes a backup of the specified directories.
  4. Sends a report to the administrator's email.

Example script:

#!/bin/bash

# Settings
WEB_SERVER="https://example.com"
BACKUP_DIR="/backup"
TARGET_DIRS="/var/www /etc"
DISK_USAGE_THRESHOLD=90
ADMIN_EMAIL="[email protected]"
DATE=$(date +"%Y-%m-%d")
BACKUP_FILE="$BACKUP_DIR/backup-$DATE.tar.gz"

# Checking web server availability
echo "Checking web server availability..."
if curl -s --head $WEB_SERVER | grep "200 OK" > /dev/null; then
echo "Web server is available."
else
echo "Warning: Web server is unavailable!" | mail -s "Problem with web server" $ADMIN_EMAIL
fi

# Checking disk space
echo "Checking disk space..."
DISK_USAGE=$(df / | grep / | awk '{ print $5 }' | sed 's/%//g')
if [ $DISK_USAGE -gt $DISK_USAGE_THRESHOLD ]; then
echo "Warning: Disk space usage exceeded $DISK_USAGE_THRESHOLD%!" | mail -s "Problem with disk space" $ADMIN_EMAIL
else
echo "There is enough disk space."
fi

# Creating backup
echo "Creating backup..."
tar -czf $BACKUP_FILE $TARGET_DIRS

if [ $? -eq 0 ]; then
echo "Backup created successfully: $BACKUP_FILE"
else
echo "Error creating backup!" | mail -s "Error creating backup" $ADMIN_EMAIL
fi

# Sending report
echo "Sending report to $ADMIN_EMAIL..."
REPORT="Report for $DATE\n\n"
REPORT+="Web server status: $(curl -s --head $WEB_SERVER | head -n 1)\n"
REPORT+="Disk space usage: $DISK_USAGE%\n"
REPORT+="Backup location: $BACKUP_FILE\n"

echo -e $REPORT | mail -s "Daily system report" $ADMIN_EMAIL

echo "Done."

Description:

  1. Check web server: Uses curl command to check if the site is available.
  2. Check disk space: Use df and awk to check disk usage. If the threshold (90%) is exceeded, a notification is sent.
  3. Create a backup: The tar command archives and compresses the directories specified in the TARGET_DIRS variable.
  4. Send a report: A report on all operations is sent to the administrator's email using mail.

How to use:

  1. Set the desired parameters, such as the web server address, directories for backup, disk usage threshold and email.
  2. Make the script executable:
chmod +x /path/to/your/script.sh
  1. Add the script to cron to run on a regular basis:
crontab -e

Example to run every day at 00:00:

0 0 * * * /path/to/your/script.sh
[–] [email protected] 1 points 1 month ago

All important files go in /data.

/data is ZFS, snapped and sent to NAS regularly

Every time I change a setting, it gets added to a dconf script. Every time I install software, I write a script.

Dotfiles git repo for home directory.

With that, I can spin up a fresh machine in minutes with scripts.

[–] [email protected] 2 points 1 month ago

You have loads of options but you need to also start from ... "what if". Work out how important your data really is. Take another look and ask the kids and others if they give a toss. You might find that no one cares about your photo collection in which case if your phone dies ... who cares? If you do care then sync them to a PC or laptop.

Perhaps take a look at this - https://www.veeam.com/products/free/linux.html its free for a few systems.

[–] [email protected] 2 points 1 month ago

If I feel like it, I might use DD to clone my drive and put in on a hard drive. Usually I don't back up, though.

[–] [email protected] 3 points 1 month ago (1 children)

The only thing I use as a backup is a Live CD that's mounted to a USB thumb drive.

I used to use Timeshift but the one time I needed it, it didn't work for some reason. It also had a problem of making my PC temporarily unusable while it was making a backup, so I didn't enable it when I had to reinstall Linux Mint.

[–] [email protected] 2 points 1 month ago

Same, Timeshift let me down one time when I needed it. I still use it though, and I'm afraid to upgrade Mint because I don't want to set my system again for of the upgrade fails to keep my configuration and Timeshift fails to take me back

[–] [email protected] 1 points 1 month ago

I sync important files to s3 from a folder with awscli. Dot files and projects are in a private git repos. That's it.

If I maintained a server, I would do something more sophisticated, but installation is so dead simple these days that I could get a daily driver in working order very quickly.

[–] [email protected] 3 points 1 month ago

I use restic, have also been looking at kopia and borg

[–] [email protected] 1 points 1 month ago* (last edited 1 month ago)

Internal RAID1 as first line of defense. Rsync to external drives where at least one is always offsite as second. Rclone to cloud storage for my most important data as the third.

Backups 2 and 3 are manual but I have reminders set and do it about once a month. I don't accrue much new data that I can't easily replace so that's fine for me.

[–] [email protected] 2 points 1 month ago* (last edited 1 month ago)

restic -> Wasabi, automated with shell script and cron. Uses an include list to tell it what paths to back up.

Script has Pushover credentials to send me backup alerts. Parses restic log to tell me how much was backed up, removed, success/failure of backup, and current repo size.

To be added: a periodic restore of a random file to have its hash compared to the current version of the file (will happen right after backup, unlikely to have changed in my workload), which will be subsequently deleted, and alert sent letting me know how the restore test went.

[–] [email protected] 3 points 1 month ago

For files are in git (using stow to recreate) and my documents folder is syncing to nextcloud (selfhosted) and this also to my laptop. This is of course not a "Backup" per se more a "multiple copies" but it gets the job done and also firs my workflow. To be happy with that I want to set up an offsite backup of data from my server to a NAS in my parents place but right now that's just a to-do I haven't put any work in yet ;)

[–] [email protected] 4 points 1 month ago

My laptop has a microsd card reader that when filled is almost flush so i just keep a micro sd card in there and have timeshift back up to it. Partitioned with full disk encryption so it cant just be stolen and scanned.

[–] [email protected] 3 points 1 month ago* (last edited 1 month ago)

Constant work in progress.

load more comments
view more: next ›