Commit c8827ceb authored by Gary Wong's avatar Gary Wong

Add a script to compress old expinfo directories.

Run it as "archive-expinfo [-t threshold]", where "threshold" is the
number of days experiments must have been inactive to be compressed
(defaulting to 1000).

Directories will be tarred and compressed in place.  For example, if
/usr/testbed/expinfo/testbed/example/1234 has been inactive for longer
than the threshold, its entire contents will be archived in
/usr/testbed/expinfo/testbed/example/1234.tar.bz2 and the original
directory removed.

The compression is extremely efficient, typically reducing directories
to around 2% of their original size.
parent ace8ba31
...@@ -25,7 +25,8 @@ SBIN_SCRIPTS = vlandiff vlansync withadminprivs export_tables cvsupd.pl \ ...@@ -25,7 +25,8 @@ SBIN_SCRIPTS = vlandiff vlansync withadminprivs export_tables cvsupd.pl \
spewconlog opsdb_control newnode suchown archive_list \ spewconlog opsdb_control newnode suchown archive_list \
wanodecheckin wanodecreate spewimage \ wanodecheckin wanodecreate spewimage \
anonsendmail epmodeset fixexpinfo node_traffic \ anonsendmail epmodeset fixexpinfo node_traffic \
dumpdescriptor subboss_tftpboot_sync testbed-control dumpdescriptor subboss_tftpboot_sync testbed-control \
archive-expinfo
WEB_SBIN_SCRIPTS= webnewnode webdeletenode webspewconlog webarchive_list \ WEB_SBIN_SCRIPTS= webnewnode webdeletenode webspewconlog webarchive_list \
webwanodecheckin webspewimage webwanodecheckin webspewimage
......
#!/bin/sh
THRESHOLD=1000
if [ "$1" = "-t" ] && [ $# -eq 2 ] && [ "$2" -gt 0 ]; then
THRESHOLD="$2"
elif [ $# -ne 0 ]; then
cat >&2 <<-EOF
Usage:
$0 [-t threshold]
EOF
exit 1
fi
find @prefix@/expinfo -depth 4 -name activity.log -mtime +"$THRESHOLD" \
-print | sed 's/.activity.log$//' | \
( while read DIRNAME; do
echo -n "Compressing $DIRNAME... "
tar cy -C "$DIRNAME/.." -f "${DIRNAME}.tar.bz2" \
`basename "$DIRNAME"` && \
chown `stat -f %u "$DIRNAME"` "${DIRNAME}.tar.bz2" && \
rm -rf "$DIRNAME"
echo done
done )
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment