-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #8 from scientist-softserv/ia-to-s3-migrator-script
IA to S3 migrator script
- Loading branch information
Showing
6 changed files
with
47 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,3 +5,5 @@ | |
!.env.development | ||
!.env.test | ||
*~undo-tree~ | ||
tmp | ||
log |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
#!/usr/bin/env ruby | ||
|
||
# Usage: bin/migrate_iaids | ||
|
||
require 'ruby-progressbar' | ||
require_relative '../lib/space_stone' | ||
|
||
puts '== Tail log/ia_to_s3_migrator.log for logs ==' | ||
|
||
iaids = File.read('tmp/iaids.txt').split("\n") | ||
logger = Logger.new('log/ia_to_s3_migrator.log') | ||
progressbar = ProgressBar.create(total: iaids.size, format: '%a %e %P% Processed: %c from %C') | ||
s3_bucket = SpaceStone::S3Service.bucket | ||
|
||
iaids.each do |iaid| | ||
# WARN: This dumbly checks for any downloads; if some files have been uploaded | ||
# but some haven't, it will skip uploading all of them | ||
if s3_bucket.objects(prefix: "#{iaid}/downloads").any? | ||
logger.warn("== #{iaid} == Files have already been uploaded to S3, skipping") | ||
else | ||
logger.info("== #{iaid} == Downloading files...") | ||
process_ia_id(iaid, '/store/tmp/fast-tmp') | ||
end | ||
progressbar.increment | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
#!/bin/bash | ||
set -e | ||
|
||
STAGE_ENV=production docker compose run \ | ||
--rm \ | ||
--remove-orphans \ | ||
--volume /store/tmp/fast-tmp:/store/tmp/fast-tmp \ | ||
web \ | ||
'bundle exec bin/ia_to_s3_migrator' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters