Ubuntu Cronjob with rsync

Currently on workplaces server we run a daily backup, due to size limits we need it to be only each third day (or something like that). We use Rsync to do the backup. What I'm thinking to do is to just change the run time of the script, so insted of daily it will run every third day.

So I want to know wether this is possible? My Concerns are that the size wont shrink because the backup will still do a "3-days backup" insted of just one day. It's hard to explain so I'll show it by exampel.

What I want:

  • Day 1 - Run Backup
  • Day 2
  • Day 3
  • Day 4 - Run Backup
  • Day 5

What I fear will happen:

  • Day 1 - Run Backup
  • Day 2 - Backup applied from Day 4
  • Day 3 - Backup applied from Day 4
  • Day 4 - Run Backup
  • Day 5

the crontab job looks like this:

5 7 * * * ../rsyncsnapshot.sh daily 30

the script looks like this

if [ $# != 2 ]; then
echo "Usage: backup.sh interval_name count"
exit 1


TIMESTAMP=`date -u "+%Y-%m-%d %H:%M:%S%z"`
echo "*** Backup started $TIMESTAMP (interval $NAME, count $COUNT) ***"

echo "Deleting $DEST_DIR/$NAME.$((COUNT-1))"
ssh $DEST_HOST rm -rf $DEST_DIR/$NAME.$(($COUNT-1))

for i in `seq $(($COUNT-1)) -1 2`;
  echo "Moving $DEST_DIR/$NAME.$j to $DEST_DIR/$NAME.$i"

echo "Copying $DEST_DIR/$NAME.0 to $DEST_DIR/$NAME.1"

echo "Copying source ($SRC) to $DEST_HOST:$DEST_DIR/$NAME.0/"
ssh $DEST_HOST touch $DEST_DIR/$NAME.0

TIMESTAMP=`date -u "+%Y-%m-%d %H:%M:%S%z"`
echo "*** Backup ended $TIMESTAMP ***"
echo "Quota as follows:"
ssh $DEST_HOST quota


To reduce the amount of space you use significantly, you'll need to reduce the number of copies you keep. This is the 2nd argument to the script. So if you run every 3 days, and want to keep a month of backups, change it to:

../rsyncsnapshot.sh daily 10

Need Your Help

ajax retrieve mysql data

html mysql ajax

I am trying to input name and phone in form and get data from mysql based on input values. When I run query by on click function the browser displays my php and query but instead of values from dat...

Facebook SDK - getting access token when user logged in

php facebook facebook-graph-api

I'm using Facebook SDK to get users logging to my web app.

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.