Class: Backup::Process
- Inherits:
-
Object
- Object
- Backup::Process
- Defined in:
- lib/backup/process.rb
Overview
Conducts the backups of a MySQL database and files.
Instance Method Summary collapse
-
#backup ⇒ Object
Creates the backup of the database and the files.
-
#initialize(backup_folder, files, override, no_compress, max_backups = 9) ⇒ Process
constructor
Takes the backup_folder where the files are backed up to.
Constructor Details
#initialize(backup_folder, files, override, no_compress, max_backups = 9) ⇒ Process
Takes the backup_folder where the files are backed up to. If override is provided the files in the backup folder are overridden. no_compress will prevent compressing the backed up files and will just copy them to the provided backup folder
17 18 19 20 21 22 23 |
# File 'lib/backup/process.rb', line 17 def initialize(backup_folder, files, override, no_compress, max_backups = 9) @backup_folder = backup_folder @files = files @override = override @no_compress = no_compress @max_backups = max_backups end |
Instance Method Details
#backup ⇒ Object
Creates the backup of the database and the files. If at least one of the provided files doesn’t exist the application will print an error message with the inexistent files and terminates
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/backup/process.rb', line 28 def backup inexistent_files = check_for_inexistent_files unless inexistent_files.empty? STDERR.puts "Cannot backup inexistent files" STDERR.puts inexistent_files.join(" ") exit 1 end FileUtils.mkdir_p @backup_folder unless File.exists? @backup_folder if @no_compress copy_files delete_uncompressed_backups else compress_files_and_copy delete_compressed_backups end end |