Skip to content

Instantly share code, notes, and snippets.

@alaniwi
Created October 2, 2017 09:32
Show Gist options
  • Save alaniwi/e9186a8b9897c77b1fcc8adf8d25b6dc to your computer and use it in GitHub Desktop.
Save alaniwi/e9186a8b9897c77b1fcc8adf8d25b6dc to your computer and use it in GitHub Desktop.
#!/bin/sh
#
# create a copy of the ESGF mirror site, consisting of hard links
#
# make it in a temporary location, and if it succeeds, rename it
# to a dated directory under the webserver (outside of the main tree)
#
# otherwise, leaves it in tmp location to be cleaned up next time
# this cron job runs.
top=/path/to/htdocs
maindir=$top/esgf
snapdir=$top/esgf_snapshots
tmpcopy=$snapdir/.partial_copy
rm -fr $tmpcopy
cp -Ral $maindir $tmpcopy
status=$?
if [ $status -eq 0 ]
then
dest=$snapdir/`date +%Y%m%d`
if [ -e $dest ] ; then dest=$snapdir/`date +%Y%m%d_%H%M%S`; fi
mv $tmpcopy $dest
fi
@alaniwi
Copy link
Author

alaniwi commented Oct 2, 2017

Script to make snapshots of esgf distribution on the rsync mirror sites.

Set the path in line 13, run daily from cron, and use script at https://gist.github.com/alaniwi/e9186a8b9897c77b1fcc8adf8d25b6dc to delete some older snapshots to reduce this to weekly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment