7.1.5. Example of a Weekly Full Backup Followed by Daily Incremental Backups

Latest response

A Weekly Full Backup Followed by Daily Incremental Backups

The script makes a full backup on a Sunday and incremental backups of the following days. Each day that a backup is made, a new subdirectory is created. This script requires a daily cron job.

so

if [[ $(date +%w) == 0 ]]; then

should be

if [[ $(date +%w) == 7 ]]; then

Responses

Hi Simeon,

Thank you for sharing this interesting and useful solution. It would be nice if you could edit your post and add more information.
Especially what gets backed up and to which location - what are the steps ... eventually providing an example would be helpful. :)

Regards,
Christian

Hi Christian,

That comes from doc https://access.redhat.com/documentation/en-us/red_hat_satellite/6.4/html/administering_red_hat_satellite/chap-red_hat_satellite-administering_red_hat_satellite-backup_and_disaster_recovery#sect-Red_Hat_Satellite-Administering_Red_Hat_Satellite-Backing_up_Satellite_Server_or_Capsule_Server-Example_Weekly_Followed_by_Daily_Backup

The if statement in documentation is false because week day for Sunday is 7 and not 0.

Thanks for clarification, Simeon ! :) Seems that I misinterpreted ... now I know you wanted to inform us about a fault.

Regards,
Christian

I have raised a documentation bug to fix this:

https://bugzilla.redhat.com/show_bug.cgi?id=1640738

Hello,

I did "man date" and saw "%w day of week (0..6); 0 is Sunday"

So no mistake here in the docs.

You're right, my fault.

But %u day of week (1..7); 1 is Monday

Where is the logic :s

Some other things are wrong in this script :

foreman-maintain backup offline --incremental --assumeyes "$LAST" $DESTINATION

This cmd will never run because param for --incremental must come just after

- LAST=$(ls -td -- $DESTINATION/*/ | head -n 1)

This will return the correct path only 1 times out of 7, I'll let you guess why.

To many errors for a so tiny script published on official documentation...

You should update your doc with something like that :

DESTINATION=/satellite/backup
if [[ $(date +%w) == 7 ]]; then
  foreman-maintain backup offline -y $DESTINATION/full
else
  LAST=$(find $DESTINATION/full/* -type d | sort -r | head -n 1)
  foreman-maintain backup offline -y -i $LAST $DESTINATION/incremental
fi
find $DESTINATION/full/* -type d -ctime +8 | xargs rm -rf
find $DESTINATION/incremental/* -type d -ctime +8 | xargs rm -rf

I will investigate this points and update you.

Thank you,

Melanie

For the command, I have opened documentation bug: https://bugzilla.redhat.com/show_bug.cgi?id=1641768 and will fix this shortly.

- LAST=$(ls -td -- $DESTINATION/*/ | head -n 1)

^ On testing, this works for us.

It seems that you want to create each incremental backup directly from the full backup so the condition from your script can be met only on Monday with that assumption.

Your script has a different approach that less effective on space but easier to restore because you just need the full backup and the increment that you need to revert. In the scripts in the docs, you also need all the increments in between. However, the script in the docs is working on testing.