0

Could someone please explain how can i loop the below logic, This logic needs to run for every week. For eg : In 1st week in source folder i have a files and folder called stack.txt, webmethods, profiles so when i ran the logic all these files are taken backup to the destination folder. In 2nd week in source folder extra directory added i.e. Kafka so now when the logic runs it should not take backup completely only the newly added things ..like Incremental backup

#!/bin/bash

# What to backup. 
Integrationserver="/home/ec2-user/source"

# Where to backup to.
dest="/home/ec2-user/destination"


# Create archive filename.
#date=$(date +%F)
IS=source
hostname=$(hostname -s)
#archive_file="$hostname-$IS-$date.tar.gz"
archive_file="$hostname-$IS.tar.gz"

# Print start status message.
echo "Backing up $Integrationserver to $dest/$archive_file"
date
echo

# Backup the files using tar.
tar --exclude=/home/ec2-user/source/logs* --exclude=/home/ec2-user/source/TC*  -zcf $dest/$archive_file $Integrationserver

# Print end status message.
echo
echo "Backup finished"
date
1
  • Why don't you just use RSNAPSHOT and crontab? (This is not an answer to your question because RSNAPSHOT is entirely different to tar and does not do compression, but it has the advantage of doing incremental backups while providing a full file tree for each incremental backup - but with only the changed files duplicated.)
    – davidgo
    Commented Jun 22, 2022 at 9:08

1 Answer 1

1

To run it multiple times at set times you should use cron or your distros equivalent.

As for doing incremental with tar files you need to use --listed-incremental

It's a bit more involved so I'll link an article that sums it up so I don't have to.

https://linuxconfig.org/how-to-create-incremental-and-differential-backups-with-tar

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .