From 7da85a4eb7f7390022c4b4758803880e3d164bb0 Mon Sep 17 00:00:00 2001 From: evazion Date: Mon, 30 Dec 2019 19:54:58 -0600 Subject: [PATCH] rake: add images:backup rake task. --- lib/tasks/images.rake | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/lib/tasks/images.rake b/lib/tasks/images.rake index 01b9e2c12..0b25ee756 100644 --- a/lib/tasks/images.rake +++ b/lib/tasks/images.rake @@ -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