Finished feature
This commit is contained in:
parent
3aae6b998a
commit
5232f2bebb
24
bucket-tool
24
bucket-tool
@ -26,7 +26,12 @@ Actions:
|
|||||||
list-files : List all files/paths that have been backed up to the bucket
|
list-files : List all files/paths that have been backed up to the bucket
|
||||||
get <entry-hash> : Get the content of a specific entry (by hash)
|
get <entry-hash> : Get the content of a specific entry (by hash)
|
||||||
restore <value> : Restore previous state of file stored in bucket. Value can be hash or filename/filepath
|
restore <value> : Restore previous state of file stored in bucket. Value can be hash or filename/filepath
|
||||||
backup <file> : Backup the file to the bucket
|
: Note: To restore to an alternate path you will need to provide the path via the -o flag
|
||||||
|
:
|
||||||
|
backup <file> : Backup the file to the bucket (will work relatively unless full path is provided)
|
||||||
|
|
||||||
|
Restore Flags:
|
||||||
|
-o | --output-file <file> : Used to provide an alternate restoral path for the restore function
|
||||||
|
|
||||||
Global Flags:
|
Global Flags:
|
||||||
-d | --debug : Set debug flag
|
-d | --debug : Set debug flag
|
||||||
@ -187,6 +192,7 @@ $CONFIG[:puppet_version]=` #{puppet_exe} --version `
|
|||||||
$CONFIG[:action]=""
|
$CONFIG[:action]=""
|
||||||
$CONFIG[:search_term]=""
|
$CONFIG[:search_term]=""
|
||||||
$CONFIG[:log_file]=""
|
$CONFIG[:log_file]=""
|
||||||
|
$CONFIG[:alt_filepath]=""
|
||||||
$CONFIG[:info_format]="inline"
|
$CONFIG[:info_format]="inline"
|
||||||
File.open('/etc/hostname') do |file|
|
File.open('/etc/hostname') do |file|
|
||||||
$HOSTNAME=file.read().strip()
|
$HOSTNAME=file.read().strip()
|
||||||
@ -250,6 +256,18 @@ while i < ARGV.count
|
|||||||
$CONFIG[:info_format]='inline'
|
$CONFIG[:info_format]='inline'
|
||||||
log "$CONFIG[:info_format] was set to #{$CONFIG[:info_format]}"
|
log "$CONFIG[:info_format] was set to #{$CONFIG[:info_format]}"
|
||||||
i+=1
|
i+=1
|
||||||
|
when '-o', '--output-file'
|
||||||
|
log "user provided ARGV[i.next] == #{ARGV[i.next]}"
|
||||||
|
if ARGV[i.next] != "" and not ARGV[i.next] =~ FLAG_REGEX
|
||||||
|
$CONFIG[:alt_filepath]=ARGV[i.next]
|
||||||
|
log "search_term was set to #{ARGV[i.next]}"
|
||||||
|
i+=2
|
||||||
|
else
|
||||||
|
puts "Flag[#{ARGV[i]}] : Argument[#{ARGV[i.next]}] : Either the argument was not provided or it was a flag"
|
||||||
|
usage
|
||||||
|
exit
|
||||||
|
end
|
||||||
|
|
||||||
else
|
else
|
||||||
i+=1
|
i+=1
|
||||||
end
|
end
|
||||||
@ -470,6 +488,10 @@ def restore_entry (bucket)
|
|||||||
entry, filepath = get_entry_by_hash bucket
|
entry, filepath = get_entry_by_hash bucket
|
||||||
end
|
end
|
||||||
|
|
||||||
|
if $CONFIG[:alt_filepath] != ""
|
||||||
|
filepath=$CONFIG[:alt_filepath]
|
||||||
|
end
|
||||||
|
|
||||||
if get_verification "Are you sure you want to overwrite #{filepath}?"
|
if get_verification "Are you sure you want to overwrite #{filepath}?"
|
||||||
File.open(filepath,'w') do |file|
|
File.open(filepath,'w') do |file|
|
||||||
file.write(entry.content)
|
file.write(entry.content)
|
||||||
|
Loading…
Reference in New Issue
Block a user