Auto-backup? Why isn't it a thing?

Suggestions for features and software you would like to see in DietPi, goes here.
Post Reply
ghettopi
Posts: 42
Joined: Tue Jul 30, 2019 8:17 pm

Auto-backup? Why isn't it a thing?

Post by ghettopi »

Why don't we have it? Even just some simple script that could be activated up backup to 'x' drive/USB on 'y' date and time. Not everyone would use it (people who need 24/7 usage and who only choose when very carefully to shut all services down for a backup) but I know many of us would still use it. I certainly would.

User avatar
johnvick
Legend
Posts: 691
Joined: Wed Jun 08, 2016 10:53 am
Location: New Zealand

Re: Auto-backup? Why isn't it a thing?

Post by johnvick »

# dietpi-backup 1

Will backup using your last settings. Write a script, make a cron job.

John

Garret
Posts: 51
Joined: Sat Nov 10, 2018 11:23 am

Re: Auto-backup? Why isn't it a thing?

Post by Garret »

@ghettopi I had found this script which seemed to be nice but to me it does not work (taken from viewtopic.php?t=3593#p12507 )

Code: Select all

MAX_BACKUPS=5
cd /mnt/data/dietpi-backup
if [[ -d dietpi-backup ]]; then
  rm dietpi-backup-$MAX_BACKUPS
  for ((i=$MAX_BACKUPS-1;i>1;i--)); do
    mv dietpi-backup-$i dietpi-backup-$( (( $i+1 )) )
  done
  mv dietpi-backup dietpi-backup-2
fi
/DietPi/dietpi/dietpi-backup 1

I would like to create maximum 5 backup folders and always delete the oldest one (I would run the script with crontab). However, that script ends to just do a dietpi-backup and never creates new folders but overwrites the same one (definitely not what I wanted).

Maybe someone could reply what is the issue :)

tjamaa
Posts: 8
Joined: Sat Sep 14, 2019 9:17 pm

Re: Auto-backup? Why isn't it a thing?

Post by tjamaa »

referring to your OP question, maybe because making a backup is rather trivial. But apart from the question what you want to back up, there are many issues to consider, e.g., media, redundancy, security, versioning, frequency, selectivity, location, longevity, accessibility, reversibility, etc. There is no unique solution and it requires a conscious decision depending very much on the criticality and relevance of the data that you would like to preserve.

On the other hand, I also have to say that when I ask family and friends if they make backups of their data the answer is always no! In most cases this is because they lack the know-how, but in any case they do not realise the potential impact of data loss. But these are also people that will not mess with Dietpi.

brtravel
Posts: 29
Joined: Sat Sep 16, 2017 1:04 pm

Re: Auto-backup? Why isn't it a thing?

Post by brtravel »

Garret wrote:
Sat Sep 14, 2019 9:20 pm
I would like to create maximum 5 backup folders and always delete the oldest one (I would run the script with crontab). However, that script ends to just do a dietpi-backup and never creates new folders but overwrites the same one (definitely not what I wanted).

Maybe someone could reply what is the issue :)
I don't know about that script, but here's a suggestion. Create your 5 backup folders manually. Set 5 different cron-jobs, one for each folder/file, staggered at the interval you want. Backup folder 1 writes today and then overwrites every 6th week, folder 2 starts next week and then overwrites every 6th week, folder 3 starts in two weeks and then overwrites every 6th week, etc.

Perhaps a little clumsy, but it's just 5 simple operations that should accomplish exactly what you describe.

Garret
Posts: 51
Joined: Sat Nov 10, 2018 11:23 am

Re: Auto-backup? Why isn't it a thing?

Post by Garret »

@brtravel Thank you for your message. It is indeed a nice idea that should be easy to implement though not "elegant" maybe :P ?!

I will work on that since I don't have any better options given that that script does not work to me :)

User avatar
MichaIng
Site Admin
Posts: 1998
Joined: Sat Nov 18, 2017 5:21 pm

Re: Auto-backup? Why isn't it a thing?

Post by MichaIng »

@Garret
The script should do what you want. It moves/renames the old backups with +1 integer suffix and only removes the oldest one. Then it creates a new backup. Some posts down the thread you linked I posted another version where the oldest backup is renamed to match the default dir, so the new backup is created by only syncing changes incrementally. By this you have least disk writes.

Post Reply