|(require (planet gh/aws:1:=5/glacier))|
Glacier provides storage for archiving. You can store objects less expensively than using S3. The trade-off is that it is very slow to retreive them.
Set the region. Defaults to "us-east-1".
Create a vault and return #t or raise exn:aws:fail?. Idempotent.
Delete a vault and return #t or raise exn:aws:fail?. Idempotent.
(list-vaults) → jsexpr?
> (list-vaults) '(#hasheq((VaultName . "testvault") (CreationDate . "2012-08-30T12:29:37.200Z") (LastInventoryDate . null) (NumberOfArchives . 0) (SizeInBytes . 0) (VaultARN . "arn:aws:glacier:us-east-1:203585791165:vaults/testvault")))
Create an archive containing the data and return its archive ID.
Create an archive with data from a file and return its archive ID.
Delete an archive.
Initiate a job to retrieve an archive’s inventory, and return the job ID.
Initiate a job to retrieve an archive’s data, and return the job ID.
Get the output of a job. If the Content-Type of the response is application/json, return the result as a jsexpr?, otherwise return it as bytes?.
Get the output of an archive retrieval job and put it in a file. Return a boolean? whether the output matches its x-amz-sha256-tree-hash.
This example can be found in examples/backup.rkt.
|;; Use Glacier for archival backups, and SDB to store the metadata.|
|(require (planet gh/aws/sdb)|
|(planet gh/http/request)) ;just for seconds->gmt-8601-string|
|(define path->archive-domain "examplesBackupPathToArchive")|
|(define archive->meta-domain "examplesBackupArchiveToMeta")|
|(define vault "examples.backup")|
|;; Creating a vault on Glacier is idempotent; harmless to do again.|
|;; Creating a domain on SDB is idempotent; harmless to do again.|
|(define/contract (archive-file path)|
|(path? . -> . void?)|
|(define path/string (path->string path))|
|;; Upload to Glacier.|
|(printf "~a\nUploading to Amazon Glacier ...\n" path/string)|
|(define archive-id (create-archive-from-file vault path))|
|;; Store some metadata on SDB.|
|;; Using the path for SDB's ItemName, store an attribute named|
|;; ArchiveId with the Glacier archive ID as the value. Remember that|
|;; SDB allows multiple values per attribute, so setting this more|
|;; than once will add more values rather than replace.|
|(printf "Updating Amazon Simple Database with metadata ...\n")|
|;; Also store some info about this specific archive.|
|`([Size ,(number->string (file-size path))]|
|(define/contract (archive-directory path [sns-topic #f])|
|((path-string?) (string?) . ->* . void?)|
|(printf "Ensuring Amazon SDB and Glacier resources are created ...\n")|
|(printf "Starting archive of all files under ~a ...\n" path)|
|(for ([x (in-directory path)])|
|;; Unless a directory or a dot file|
|(unless (or (directory-exists? x)|
|(equal? #\. (string-ref (path->string x) 0)))|
|(publish sns-topic (format "Archive completed ~a." (seconds->gmt-string))))|
|;; For example let's archive the file in our tests dir.|
|(path->string (simplify-path (path->complete-path (build-path 'up "tests")))))|
|;; Let's notify to our first SNS topic (if any)|
|(define sns-topic (match (list-topics) [(list x rest ...) x][else #f]))|
|(archive-directory root-dir sns-topic)|
|;; Let's look at the information from SDB|
|(select-hash (format "SELECT * FROM ~a" path->archive-domain))|
|(select-hash (format "SELECT * FROM ~a" archive->meta-domain))|