debian-mirror-gitlab/lib/tasks/gitlab/lfs/migrate.rake

37 lines
1.3 KiB
Ruby
Raw Normal View History

2021-03-11 19:13:27 +05:30
# frozen_string_literal: true
2018-05-09 12:01:36 +05:30
require 'logger'
2020-03-13 15:44:24 +05:30
desc "GitLab | LFS | Migrate LFS objects to remote storage"
2018-05-09 12:01:36 +05:30
namespace :gitlab do
namespace :lfs do
task migrate: :environment do
2021-09-04 01:27:46 +05:30
logger = Logger.new($stdout)
2018-05-09 12:01:36 +05:30
logger.info('Starting transfer of LFS files to object storage')
LfsObject.with_files_stored_locally
.find_each(batch_size: 10) do |lfs_object|
2020-11-24 15:15:51 +05:30
lfs_object.file.migrate!(LfsObjectUploader::Store::REMOTE)
2019-07-07 11:18:12 +05:30
2020-11-24 15:15:51 +05:30
logger.info("Transferred LFS object #{lfs_object.oid} of size #{lfs_object.size.to_i.bytes} to object storage")
2021-06-08 01:23:25 +05:30
rescue StandardError => e
2020-11-24 15:15:51 +05:30
logger.error("Failed to transfer LFS object #{lfs_object.oid} with error: #{e.message}")
end
2018-05-09 12:01:36 +05:30
end
2019-12-21 20:55:43 +05:30
task migrate_to_local: :environment do
2021-09-04 01:27:46 +05:30
logger = Logger.new($stdout)
2019-12-21 20:55:43 +05:30
logger.info('Starting transfer of LFS files to local storage')
LfsObject.with_files_stored_remotely
.find_each(batch_size: 10) do |lfs_object|
lfs_object.file.migrate!(LfsObjectUploader::Store::LOCAL)
logger.info("Transferred LFS object #{lfs_object.oid} of size #{lfs_object.size.to_i.bytes} to local storage")
2021-06-08 01:23:25 +05:30
rescue StandardError => e
2019-12-21 20:55:43 +05:30
logger.error("Failed to transfer LFS object #{lfs_object.oid} with error: #{e.message}")
end
end
2018-05-09 12:01:36 +05:30
end
end