Module: OllamaChat::Utils::Backup
- Included in:
- Tools::Concern
- Defined in:
- lib/ollama_chat/utils/backup.rb
Overview
Utility module for handling file backups. This module provides methods to create timestamped copies of files in a designated backup directory within the XDG state home.
Instance Method Summary collapse
-
#perform_backup(path) ⇒ Pathname
Creates a timestamped backup of the specified file.
Instance Method Details
#perform_backup(path) ⇒ Pathname
Creates a timestamped backup of the specified file.
The backup is stored in OC::XDG_STATE_HOME/backups, preserving the original directory structure.
12 13 14 15 16 17 18 19 20 |
# File 'lib/ollama_chat/utils/backup.rb', line 12 def perform_backup(path) path.exist? or return backups_dir = OC::XDG_STATE_HOME + 'backups' = Time.now.strftime('%Y%m%d%H%M%S') backup_path = Pathname.new(backups_dir.to_s + path.to_s + ?- + ) backup_path.dirname.mkpath FileUtils.cp path, backup_path backup_path end |