Instantly share code, notes, and snippets.

Embed
What would you like to do?
Sync Ubuntu Mirror v1
### Admin email address
admin_email=admin@domain.com
### Setup the server to mirror
mirror=rsync://archive.ubuntu.com/ubuntu
### Log file path
log=/var/log/ubuntu
### Setup the local directory
local=/mirror/ubuntu
echo "`date` Ubuntu Mirror Sync Started" >> $log
if [[ $1 == "debug" ]]; then
rsync -a --delete-after --progress $mirror $local
status=$?
else
rsync -a --delete-after $mirror $local >> $log
status=$?
# Send an email after completion
if [[ -x /usr/bin/mail && "$sendemail" -eq "1" ]]; then
mail -s "Ubuntu Mirror Sync Complete" "$admin_email" <<OUTMAIL
Ubuntu Mirror Sync
PID: $$
Finish Time: `date`
OUTMAIL
fi
fi
echo "`date` Ubuntu Mirror Sync Complete" >> $log
exit 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment