saltyorg / Saltbox

Ansible-based solution for rapidly deploying a Docker containerized cloud media server.
https://docs.saltbox.dev
GNU General Public License v3.0
573 stars 65 forks source link

Backing up and restoring individual app directories #66

Open vpatel9202 opened 2 years ago

vpatel9202 commented 2 years ago

Describe the problem There are certain use cases where it would make sense to back up only a given app rather than running a full backup. For example, I have thumbnails enabled for Plex so my plex directory is absolutely massive relative to the rest of my apps. I'm okay with the compromise of less frequent backups for my Plex directory in order to maintain the thumbnails, but I don't want the rest of my apps to be beholden to the same less-frequent backup settings.

On the other hand, there are times when an app will fail for whatever reason and I want to restore only that specific app from a backup. The only way to do this currently is to manually download the tar for that app and replace the current app directory with the download.

Describe any solutions you think might work The way I would imagine this working would be via a command such as sb backup plex which would then only backup /opt/plex. Similarly sb restore plex would pull the most recent archived version of the directory and replace the current directory. Allowing users to select which backup to restore from if multiple archived versions exist may be more difficult since I'm not sure there's anyway for Ansible to list available backups by date and have you select one.

Utilizing the automated backups on an app-by-app basis would be more difficult but a reworked backup_config.yml sample below shows one possibility. In this configuration, a complete backup of all apps would occur monthly, while a partial backup of some key apps occurs more frequently.

backup:
  local:
    enable: true
    destination: /mnt/local/Backups/Saltbox
  rclone:
    enable: true
    destination: google:/Backups/Saltbox
  rsync:
    enable: false
    destination: rsync://somehost.com/Backups/Saltbox
    port: 22
  restore_service:
    user: # 
    pass: # 
  misc:
    snapshot: true # 
  cron:
    full_backup:
      enable: true
      cron_time: monthly
    partial_backup:
      enable: true
      include:
        - radarr   # or /opt/radarr
        - sonarr   # or /opt/sonarr
        - prowlarr # or /opt/prowloarr
        - nzbget   # or /opt/nzbget
      cron_time: weekly

Additionally, partial backups would make even more sense for people who are not using btrfs as they would be able to backup their lighter apps quickly with little downtime and save the big stuff for a better time.

saltydk commented 2 years ago

Just use btrfs on the /opt partition and most of this isn't a problem. Frankly this seems like overengineering a solution to combat bad system setup that potentially could have plenty of downsides on the support side of things for years to come.

If you want to do a Pull Request for a separate Backup role that does all this then by all means submit one but I don't see much benefit to doing this outside of maybe adding the individual app restore bit at some point but outside of that I will likely not want to go this route.

Duplicacy (incremental backups) would probably solve the issue with big app data folders so if we improve upon backup/restore that is likely the way we'll go instead of a complicated filtering solution which will likely need a complete rewrite as well but without giving more than a handful of users any benefits.

chazlarson commented 2 years ago

Some of this could be implemented with no code changes by adding a script that swapped in relevant backup_excludes.txt files on a schedule.

saltydk commented 2 years ago

If we ignore how restore would work, sure.

chazlarson commented 2 years ago

Yeah, I was mostly thinking of the "only back plex up once a week" part.

vpatel9202 commented 2 years ago

@saltydk incremental backups would absolutely solve the problem.