r110561 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r110560‎ | r110561 | r110562 >
Date:11:26, 2 February 2012
Author:ariel
Status:deferred
Tags:
Comment:
option to list dump dirs only w/o file contents
Modified paths:
  • /branches/ariel/xmldumps-backup/create-rsync-list.sh (modified) (history)

Diff [purge]

Index: branches/ariel/xmldumps-backup/create-rsync-list.sh
@@ -5,6 +5,7 @@
66 # are not n successful dumps available.
77
88 # Options:
 9+# dirsonly -- list only the directories to include
910 # dumpsnumber -- number of dumps to list
1011 # outputfile -- path to file in which to write the list
1112 # configfile -- path to config file used to generate dumps
@@ -12,6 +13,7 @@
1314 usage() {
1415 echo "Usage: $0 --dumpsnumber n --outputfile filename --configfile filename --rsyncprefix path"
1516 echo
 17+ echo " dirsonly list only directories to include"
1618 echo " dumpsnumber number of dumps to list"
1719 echo " outputfile name of file to which we will write iw action list"
1820 echo " configfile name of configuration file for dump generation"
@@ -21,6 +23,7 @@
2224 echo
2325 echo "For example:"
2426 echo " $0 --dumpsnumber 5 --outputfile /data/dumps/public/dumpsfiles_for_rsync.txt --configfile wikidump.conf.testing"
 27+
2528 exit 1
2629 }
2730
@@ -74,22 +77,34 @@
7578 done
7679 }
7780
 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+
7889 list_files_in_dir() {
7990 if [ ! -f "$outputfile.tmp" ]; then
8091 touch $outputfile.tmp
8192 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
88107 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
94109 fi
95110 }
96111
@@ -121,7 +136,7 @@
122137 fi
123138 }
124139
125 -if [ "$#" -lt "4" -o "$#" -gt "8" ]; then
 140+if [ "$#" -lt "4" -o "$#" -gt "9" ]; then
126141 usage
127142 fi
128143
@@ -129,21 +144,28 @@
130145 outputfile=""
131146 configfile="wikidump.conf"
132147 rsyncprefix="false"
 148+dirsonly="false"
133149
134150 while [ $# -gt 0 ]; do
135 - if [ $1 == "--dumpsnumber" ]; then
 151+ if [ $1 == "--dirsonly" ]; then
 152+ dirsonly="true"
 153+ shift
 154+ elif [ $1 == "--dumpsnumber" ]; then
136155 dumpsnumber="$2"
 156+ shift; shift
137157 elif [ $1 == "--outputfile" ]; then
138158 outputfile="$2"
 159+ shift; shift
139160 elif [ $1 == "--configfile" ]; then
140161 configfile="$2"
 162+ shift; shift
141163 elif [ $1 == "--rsyncprefix" ]; then
142164 rsyncprefix="$2"
 165+ shift; shift
143166 else
144167 echo "$0: Unknown option $1"
145168 usage
146169 fi
147 - shift; shift
148170 done
149171
150172 check_args

Status & tagging log