diff options
-rwxr-xr-x | byteback-snapshot | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/byteback-snapshot b/byteback-snapshot index 0f0c9e9..d3645b5 100755 --- a/byteback-snapshot +++ b/byteback-snapshot @@ -26,11 +26,14 @@ end fatal("--root not readable") unless File.directory?("#{@root}") @backups = BackupDirectory.new(@root) +snapshots = @backups.snapshots -last_snapshot_time = @backups.snapshots.last.time -fatal("Last snapshot was less than six hours ago") unless - !last_snapshot_time || - Time.now - last_snapshot_time >= 6*60*60 # FIXME: make configurable +if !snapshots.empty? + last_snapshot_time = snapshots.last.time + fatal("Last snapshot was less than six hours ago") unless + !last_snapshot_time || + Time.now - last_snapshot_time >= 6*60*60 # FIXME: make configurable +end info "Making new snapshot" @backups.new_snapshot! |