#!/bin/bash # calculate dates - you can adjust this to match the frequency you run the job sd=`date +%Y%m%d --date="7 days ago"` ed=`date +%Y%m%d --date="1 day ago"` # substitute your base email-backup directory here d="/home/mark/email-backup" backup_dir="$sd-$ed" # Change to your base directory cd $d # if the backup directory exists, we'll just overwrite the contents # otherwise, create it if [ ! -d $backup_dir ]; then mkdir $backup_dir fi # descend into the gmail backup directory cd "$d/gmail-backup-0.104-linux" # define it cmd="./gmail-backup.sh backup ../$backup_dir/ [your_email] [your_password] $sd $ed" # do it exec $cmd