Class: StellarCoreBackup::Restore::Filesystem
- Inherits:
-
Filesystem
- Object
- Filesystem
- StellarCoreBackup::Restore::Filesystem
- Includes:
- Contracts
- Defined in:
- lib/stellar-core-backup/restore/filesystem.rb
Defined Under Namespace
Classes: DataDirNotEmpty
Instance Attribute Summary collapse
-
#core_data_dir ⇒ Object
readonly
Returns the value of attribute core_data_dir.
Instance Method Summary collapse
- #core_data_dir_empty? ⇒ Boolean
-
#initialize(config) ⇒ Filesystem
constructor
A new instance of Filesystem.
- #restore(backup_archive) ⇒ Object
Methods inherited from Filesystem
Constructor Details
#initialize(config) ⇒ Filesystem
Returns a new instance of Filesystem.
10 11 12 13 14 |
# File 'lib/stellar-core-backup/restore/filesystem.rb', line 10 def initialize(config) @config = config @working_dir = StellarCoreBackup::Utils.create_working_dir(@config.get('working_dir')) @core_data_dir = get_core_data_dir(@config.get('core_config')) end |
Instance Attribute Details
#core_data_dir ⇒ Object (readonly)
Returns the value of attribute core_data_dir.
7 8 9 |
# File 'lib/stellar-core-backup/restore/filesystem.rb', line 7 def core_data_dir @core_data_dir end |
Instance Method Details
#core_data_dir_empty? ⇒ Boolean
25 26 27 28 29 30 31 32 33 |
# File 'lib/stellar-core-backup/restore/filesystem.rb', line 25 def core_data_dir_empty?() # checks fs and asks user to remove fs manually if fs is already in place. if (Dir.entries(@core_data_dir) - %w{ . .. }).empty? then return true else puts "error: #{@core_data_dir} is not empty, you can only restore to an empty data directory" raise DataDirNotEmpty end end |
#restore(backup_archive) ⇒ Object
19 20 21 22 |
# File 'lib/stellar-core-backup/restore/filesystem.rb', line 19 def restore(backup_archive) # unpack the filesystem backup puts "info: stellar-core buckets restored" if StellarCoreBackup::Tar.unpack("#{@working_dir}/core-fs.tar", @core_data_dir) end |