-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy patharchive
More file actions
executable file
·46 lines (37 loc) · 1.12 KB
/
archive
File metadata and controls
executable file
·46 lines (37 loc) · 1.12 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
#!/bin/bash
# History
# 080512 ksl Updated so could give special designation, e.g an old date to the
# file if that was desired
# 090528 ksl Removed dependencies on other routines
if [ $# -lt 1 ]
then
echo "Usage: Archive [-x special] dirname"
echo "Normally Archive dirname produces z.dirname.date.gz"
echo "-x replaces date with whatever special word one chooses"
exit
fi
if [ $1 = "-x" ]
then
NEWDIRNAME=$3.$2
XDIR=$3
else
NEWDIRNAME=$1.`date "+%y%m%d"`
XDIR=$1
fi
# Now make a cp of the diretory we want to archive in tmp, since we don't want to
# do anything to this version of this directory
CURDIR=`pwd`
ME=`whoami`
mkdir tmp
rsync -au $XDIR tmp
cd tmp
ls
echo The new directory name: $NEWDIRNAME
mv $XDIR $NEWDIRNAME
echo Archive of $1 on `date "+%y%m%d"` from $CURDIR by $ME >>$NEWDIRNAME/History.txt
find $NEWDIRNAME \( -name 'trace' -o -name 'core.*' -o -name '*.o' -o -name '*.ispy' -o -name '*~' -o -name '*pyc' \) -print -exec rm {} \; -o -fstype nfs -prune
tar cvzf $NEWDIRNAME.tar.gz $NEWDIRNAME
mv $NEWDIRNAME.tar.gz ../z.$NEWDIRNAME.tar.gz
# Now cleanup
cd ..
rm -r -f tmp