Skip to content

Commit a6a3516

Browse files
authored
Remove old backup files
1 parent 8cf602a commit a6a3516

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

backup.rb

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616

1717
backup_name = "#{now.to_s.gsub(' ', '_')}.pg_dump" # name of the created backup file
1818
backup_file_path = "/tmp/#{backup_name}"
19+
backup_files = "/tmp/*.pg_dump"
1920
backup_folder = "/#{db_to_backup}"
2021
oldest_backup_date = (now.to_datetime << 1).to_time # More than a month old
2122

@@ -40,7 +41,7 @@
4041
client.upload "#{backup_folder}/#{backup_name}", File.read(backup_file_path)
4142

4243
#####################
43-
# Delete old backups
44+
# Delete old backups in dropbox
4445
#####################
4546
files = client.list_folder backup_folder
4647
files.each do |file|
@@ -49,3 +50,5 @@
4950
client.delete file.path_lower
5051
end
5152
end
53+
54+
system("rm", backup_files)

0 commit comments

Comments
 (0)