From: Carl N Baldwin Date: Thu, 20 Oct 2005 16:31:26 +0000 (-0600) Subject: Wrote some ruby scripts to help with restore X-Git-Tag: release-0.4~90 X-Git-Url: http://git.pippins.net/embedvideo/.git/%22%22.%24thumbnail.%22/%7Bedit%7D?a=commitdiff_plain;h=cbfcd06cb32cc5c35bfb8ddb499cb952024068a4;p=backups%2F.git Wrote some ruby scripts to help with restore --- diff --git a/scripts/Makefile.am b/scripts/Makefile.am index 1d1126c..6711a00 100644 --- a/scripts/Makefile.am +++ b/scripts/Makefile.am @@ -1,4 +1,5 @@ bin_SCRIPTS = \ + files-from-date.rb \ find-cmd.sh \ list-dates.rb \ other-commands \ diff --git a/scripts/files-from-date.rb b/scripts/files-from-date.rb new file mode 100755 index 0000000..4fde0c5 --- /dev/null +++ b/scripts/files-from-date.rb @@ -0,0 +1,15 @@ +#!/usr/bin/ruby + +# Make sure the record separator is zero rather than new-line +$/ = "\0" + +# The only argument is the date for which to list files +date = ARGV.shift.to_i + +ARGF.each do |line| + # The seventh and eigth fields are the backup date and the file name. + backupdate,name = line.split( ' ', 8 )[6,7] + + # Print the name if the backup date matches + print name if date == backupdate.to_i +end diff --git a/scripts/find-cmd.sh b/scripts/find-cmd.sh index 964dd15..d9efb29 100755 --- a/scripts/find-cmd.sh +++ b/scripts/find-cmd.sh @@ -2,6 +2,6 @@ { for type in d f l; do - find . -type $type -printf "$type %#m %u %g %s %CY%Cm%Cd%CH%CM%CS 0 %p\0" + find . -type $type -printf "$type %#m %u %g %s %CY%Cm%Cd%CH%CM%CS %CS %p\0" done } diff --git a/scripts/list-dates.rb b/scripts/list-dates.rb index b8a5c50..18cdef9 100755 --- a/scripts/list-dates.rb +++ b/scripts/list-dates.rb @@ -1,14 +1,17 @@ #!/usr/bin/ruby +# Make sure the record separator is zero rather than new-line +$/ = "\0" + +# Create a set of backup dates require 'set' +dates = SortedSet.new -dates = Set.new +# Split each input record into 8 fields on spaces and grab the 7th as integer +date_array = ARGF.map { |rec| rec.split( ' ', 8 )[6].to_i } -ARGF.each( "\0" ) do |line| - fields = line.split ' ', 8 - dates.add fields[6] -end +# Merge the dates into the set +dates.merge date_array -dates.each do |date| - puts date -end +# Output the sorted set +puts dates.to_a