I want to make a script or scripts to auto backup but have no experience making any scripts and would appreciate any help or input. Some outlines

script -Make a backup of my Main folder in another folder in my home directory named Backups every 6 hours and keep only 12 backups at a time(3 days). Each backup is timestamped with data and time along with name Main

-Make a backup of my Main folder to my internal hard drive every 6 hours and keep only 12 backups at a time((3 days). Each backup is timestamped with data and time along with name Main

-Take the latest backup folder and create an encrypted tar file from it.Use rclone to upload the tar file to my google drive every 3 days.Each backup is timestamped with data and time along with name Main

Optional -Configure some kind of notification system to inform me to make an offline backup to my external hard drive/USB thumb drive once a week(it would be nice if can i sync the notifications between my PC and Android phone but not sure if that’s possible)

-Is there a way to do incremental backups for the first two backups

Software i know of -rclone(i use it manually upload my encrypted backups to my google drive)

-BorgBackup(the one in Linux mint repo is outdated thought 1.2.8v instead of 1.4v)

-rsync

-FreeFileSync

-duplicity(also outdated 2.1.4v instead of 3.0.4)

  • isgleas@lemmy.ml
    link
    fedilink
    arrow-up
    4
    ·
    2 days ago

    Nice homework you got there. Imo you need to read the manpages for cron or systemd timers, to schedule your tasks. Any cloud based calendar app can help you for the notification. And I think any genai tool can get you a suitable chunk of code depending on your specifics about the scripting.

  • kbal@fedia.io
    link
    fedilink
    arrow-up
    2
    ·
    2 days ago

    I was going to give some suggestions, but it’s easiest to say it like this:

    if ( ! test -d ~/Backups ) ; then exit; fi
    cd ~/Backups
    count=`ls -d Main-* | wc -l`
    if [ count -gt 11] ; then 
        rm -rf `ls -rtd Main-* | head -$((count - 11))`
    fi
    rsync -aL ~/Main Main-`date -Ihours`
    

    You’d run something like that every six hours. Don’t expect it to work, but maybe it could help get you started.

    • kbal@fedia.io
      link
      fedilink
      arrow-up
      4
      ·
      2 days ago

      By the way, don’t forget to make a good backup before you start messing with backup scripts. Also, if the reason you’re keeping twelve different backups is to see how things changed over time, put it in git instead.