Subversion Repositories wimsdev

Rev

Rev 16591 | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
16592 obado 1
# RestoreClassBackup job
2
# Restore a backup of the class with id=`qclass` saved at year `data1`.
16591 obado 3
 
4
!read jobs/listclassbackups.proc
5
 
6
!if $qclass = *
7
  error=You must specify one class ID to restore.
8
  !exit
9
!endif
10
 
11
!! backup_year is mandatory
12
!if $backup_year = $empty
13
  error=wrong or empty backup year in data1 ($backup_year)
14
  !exit
15
!endif
16
 
17
!if $cnt <= 0
18
  error=No backup available for class $qclass on year $backup_year.
19
  !exit
20
!endif
21
 
22
date=!char 1 to 8 of $wims_now
23
month=!char 5 to 6 of $date
24
!if $month=12
25
  date=$[$date+10000 - 1100]
26
!else
27
  date=$[$date+100]
28
!endif
29
 
30
test=!sh cd $wims_home\
31
cp backup/oldclasses/$backup_year/$qclass.tgz log/classes/\
32
cd $wims_home/log/classes/\
33
if [ ! `ls -d $qclass | wc -c` -eq 0 ] ; then echo "already existing class id $qclass; nothing was done." ; exit ; fi ;\
34
tar xzf $qclass.tgz\
35
perl -np -i -e "s:class_expiration=.*:class_expiration=$date:g" $qclass/.def\
36
rm $qclass.tgz\
37
cd $wims_home; mkdir -p backuprestore/$backup_year; mv backup/oldclasses/$backup_year/$qclass.tgz backuprestore/$backup_year
38
 
39
!if $test!=$empty
40
  error=$test
41
  !reset test
42
  !sh cd $wims_home/log/classes/ ; rm -f $qclass.tgz
43
!endif