Index: branches/ariel/xmldumps-backup/create-rsync-list.sh |
— | — | @@ -5,6 +5,7 @@ |
6 | 6 | # are not n successful dumps available. |
7 | 7 | |
8 | 8 | # Options: |
| 9 | +# dirsonly -- list only the directories to include |
9 | 10 | # dumpsnumber -- number of dumps to list |
10 | 11 | # outputfile -- path to file in which to write the list |
11 | 12 | # configfile -- path to config file used to generate dumps |
— | — | @@ -12,6 +13,7 @@ |
13 | 14 | usage() { |
14 | 15 | echo "Usage: $0 --dumpsnumber n --outputfile filename --configfile filename --rsyncprefix path" |
15 | 16 | echo |
| 17 | + echo " dirsonly list only directories to include" |
16 | 18 | echo " dumpsnumber number of dumps to list" |
17 | 19 | echo " outputfile name of file to which we will write iw action list" |
18 | 20 | echo " configfile name of configuration file for dump generation" |
— | — | @@ -21,6 +23,7 @@ |
22 | 24 | echo |
23 | 25 | echo "For example:" |
24 | 26 | echo " $0 --dumpsnumber 5 --outputfile /data/dumps/public/dumpsfiles_for_rsync.txt --configfile wikidump.conf.testing" |
| 27 | + |
25 | 28 | exit 1 |
26 | 29 | } |
27 | 30 | |
— | — | @@ -74,22 +77,34 @@ |
75 | 78 | done |
76 | 79 | } |
77 | 80 | |
| 81 | +list_dir_only() { |
| 82 | + if [ "$rsyncprefix" == "false" ]; then |
| 83 | + ls -d $d 2>/dev/null >> $outputfile.tmp |
| 84 | + else |
| 85 | + ls -d $d 2>/dev/null | sed -e "s|^$publicdir|$rsyncprefix|" >> $outputfile.tmp |
| 86 | + fi |
| 87 | +} |
| 88 | + |
78 | 89 | list_files_in_dir() { |
79 | 90 | if [ ! -f "$outputfile.tmp" ]; then |
80 | 91 | touch $outputfile.tmp |
81 | 92 | fi |
82 | | - if [ "$rsyncprefix" == "false" ]; then |
83 | | - ls $d/*.gz 2>/dev/null >> $outputfile.tmp |
84 | | - ls $d/*.bz2 2>/dev/null >> $outputfile.tmp |
85 | | - ls $d/*.7z 2>/dev/null >> $outputfile.tmp |
86 | | - ls $d/*.html 2>/dev/null >> $outputfile.tmp |
87 | | - ls $d/*.txt 2>/dev/null >> $outputfile.tmp |
| 93 | + if [ "$dirsonly" == false ]; then |
| 94 | + if [ "$rsyncprefix" == "false" ]; then |
| 95 | + ls $d/*.gz 2>/dev/null >> $outputfile.tmp |
| 96 | + ls $d/*.bz2 2>/dev/null >> $outputfile.tmp |
| 97 | + ls $d/*.7z 2>/dev/null >> $outputfile.tmp |
| 98 | + ls $d/*.html 2>/dev/null >> $outputfile.tmp |
| 99 | + ls $d/*.txt 2>/dev/null >> $outputfile.tmp |
| 100 | + else |
| 101 | + ls $d/*.gz 2>/dev/null | sed -e "s|^$publicdir|$rsyncprefix|" >> $outputfile.tmp |
| 102 | + ls $d/*.bz2 2>/dev/null | sed -e "s|^$publicdir|$rsyncprefix|" >> $outputfile.tmp |
| 103 | + ls $d/*.7z 2>/dev/null | sed -e "s|^$publicdir|$rsyncprefix|" >> $outputfile.tmp |
| 104 | + ls $d/*.html 2>/dev/null | sed -e "s|^$publicdir|$rsyncprefix|" >> $outputfile.tmp |
| 105 | + ls $d/*.txt 2>/dev/null | sed -e "s|^$publicdir|$rsyncprefix|" >> $outputfile.tmp |
| 106 | + fi |
88 | 107 | else |
89 | | - ls $d/*.gz 2>/dev/null | sed -e "s|^$publicdir|$rsyncprefix|" >> $outputfile.tmp |
90 | | - ls $d/*.bz2 2>/dev/null | sed -e "s|^$publicdir|$rsyncprefix|" >> $outputfile.tmp |
91 | | - ls $d/*.7z 2>/dev/null | sed -e "s|^$publicdir|$rsyncprefix|" >> $outputfile.tmp |
92 | | - ls $d/*.html 2>/dev/null | sed -e "s|^$publicdir|$rsyncprefix|" >> $outputfile.tmp |
93 | | - ls $d/*.txt 2>/dev/null | sed -e "s|^$publicdir|$rsyncprefix|" >> $outputfile.tmp |
| 108 | + list_dir_only |
94 | 109 | fi |
95 | 110 | } |
96 | 111 | |
— | — | @@ -121,7 +136,7 @@ |
122 | 137 | fi |
123 | 138 | } |
124 | 139 | |
125 | | -if [ "$#" -lt "4" -o "$#" -gt "8" ]; then |
| 140 | +if [ "$#" -lt "4" -o "$#" -gt "9" ]; then |
126 | 141 | usage |
127 | 142 | fi |
128 | 143 | |
— | — | @@ -129,21 +144,28 @@ |
130 | 145 | outputfile="" |
131 | 146 | configfile="wikidump.conf" |
132 | 147 | rsyncprefix="false" |
| 148 | +dirsonly="false" |
133 | 149 | |
134 | 150 | while [ $# -gt 0 ]; do |
135 | | - if [ $1 == "--dumpsnumber" ]; then |
| 151 | + if [ $1 == "--dirsonly" ]; then |
| 152 | + dirsonly="true" |
| 153 | + shift |
| 154 | + elif [ $1 == "--dumpsnumber" ]; then |
136 | 155 | dumpsnumber="$2" |
| 156 | + shift; shift |
137 | 157 | elif [ $1 == "--outputfile" ]; then |
138 | 158 | outputfile="$2" |
| 159 | + shift; shift |
139 | 160 | elif [ $1 == "--configfile" ]; then |
140 | 161 | configfile="$2" |
| 162 | + shift; shift |
141 | 163 | elif [ $1 == "--rsyncprefix" ]; then |
142 | 164 | rsyncprefix="$2" |
| 165 | + shift; shift |
143 | 166 | else |
144 | 167 | echo "$0: Unknown option $1" |
145 | 168 | usage |
146 | 169 | fi |
147 | | - shift; shift |
148 | 170 | done |
149 | 171 | |
150 | 172 | check_args |