Skip to content

Instantly share code, notes, and snippets.

@prashanthrajagopal
Last active December 8, 2019 01:38
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save prashanthrajagopal/11212269 to your computer and use it in GitHub Desktop.
Save prashanthrajagopal/11212269 to your computer and use it in GitHub Desktop.
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