rake: add images:backup rake task.

This commit is contained in:
evazion
2019-12-30 19:54:58 -06:00
parent fe0bb1e602
commit 7da85a4eb7

View File

@@ -1,2 +1,16 @@
namespace :images do
desc "Backup images"
task :backup => :environment do
CurrentUser.user = User.system
sm = Danbooru.config.backup_storage_manager
tags = ENV["BACKUP_TAGS"]
posts = Post.tag_match(tags)
posts.find_each do |post|
sm.store_file(post.file(:preview), post, :preview) if post.has_preview?
sm.store_file(post.file(:crop), post, :crop) if post.has_cropped?
sm.store_file(post.file(:sample), post, :sample) if post.has_large?
sm.store_file(post.file(:original), post, :original)
end
end
end