file copy-by-id
Copy a file version to the given bucket (server-side, not via download+upload).
Copies the contents of the source B2 file to destination bucket and assigns the given name to the new B2 file, possibly setting options like server-side encryption and retention.
Warning
Setting file retention mode to ‘compliance’ is irreversible - such files can only be ever deleted after their retention period passes, regardless of keys (master or not) used. This is especially dangerous when setting bucket default retention, as it may lead to high storage costs.
By default, it copies the file info and content type, therefore --content-type
and --info
are optional.
If one of them is set, the other has to be set as well.
To force the destination file to have empty fileInfo, use --no-info
.
By default, the whole file gets copied, but you can copy an (inclusive!) range of bytes
from the source file to the new file using --range
option.
Each --info
entry is in the form a=b
, you can specify many.
The maximum file size is 5GB or 10TB, depending on capability of installed b2sdk
version.
To request SSE-B2 or SSE-C encryption for destination files,
please set --destination-server-side-encryption=SSE-B2/SSE-C
.
The default algorithm is set to AES256 which can be changed
with --destination-server-side-encryption-algorithm
parameter.
Using SSE-C requires providing B2_DESTINATION_SSE_C_KEY_B64
environment variable,
containing the base64 encoded encryption key.
If B2_DESTINATION_SSE_C_KEY_ID
environment variable is provided,
it’s value will be saved as sse_c_key_id
in the
uploaded file’s fileInfo.
To access SSE-C encrypted files,
please set --source-server-side-encryption=SSE-C
.
The default algorithm is set to AES256 which can by changed
with --source-server-side-encryption-algorithm
parameter.
Using SSE-C requires providing B2_SOURCE_SSE_C_KEY_B64
environment variable,
containing the base64 encoded encryption key.
Setting file retention settings requires the writeFileRetentions capability, and only works in bucket
with fileLockEnabled=true. Providing --file-retention-mode
requires providing --retain-until
which has to
be a future timestamp, in the form of an integer representing milliseconds
since epoch. Leaving out these options results in a file retained according to bucket defaults.
Setting legal holds requires the writeFileLegalHolds capability, and only works in bucket with fileLockEnabled=true.
If either the source or the destination uses SSE-C and --content-type
and --info
are not provided, then
to perform the copy the source file’s metadata has to be fetched first - an additional request to B2 cloud has
to be made. To achieve that, provide --fetch-metadata
. Without that flag, the command will fail.
Requires capability:
readFiles (if
sourceFileId
bucket is private)writeFiles
b2 file copy-by-id [-h] [--fetch-metadata] [--content-type CONTENT_TYPE]
[--range RANGE] [--info INFO | --no-info]
[--cache-control CACHE_CONTROL]
[--content-disposition CONTENT_DISPOSITION]
[--content-encoding CONTENT_ENCODING]
[--content-language CONTENT_LANGUAGE] [--expires EXPIRES]
[--destination-server-side-encryption {SSE-B2,SSE-C}]
[--destination-server-side-encryption-algorithm {AES256}]
[--source-server-side-encryption {SSE-C}]
[--source-server-side-encryption-algorithm {AES256}]
[--file-retention-mode {compliance,governance}]
[--retain-until TIMESTAMP] [--legal-hold {on,off}]
sourceFileId destinationBucketName b2FileName
Positional Arguments
- sourceFileId
- destinationBucketName
- b2FileName
Named Arguments
- --fetch-metadata
Default: False
- --content-type
- --range
- --info
- --no-info
Default: False
- --cache-control
optional Cache-Control header, value based on RFC 2616 section 14.9, example: ‘public, max-age=86400’)
- --content-disposition
optional Content-Disposition header, value based on RFC 2616 section 19.5.1, example: ‘attachment; filename=”fname.ext”’
- --content-encoding
optional Content-Encoding header, value based on RFC 2616 section 14.11, example: ‘gzip’
- --content-language
optional Content-Language header, value based on RFC 2616 section 14.12, example: ‘mi, en’
- --expires
optional Expires header, value based on RFC 2616 section 14.21, example: ‘Thu, 01 Dec 2050 16:00:00 GMT’
- --destination-server-side-encryption
Possible choices: SSE-B2, SSE-C
- --destination-server-side-encryption-algorithm
Possible choices: AES256
Default: “AES256”
- --source-server-side-encryption
Possible choices: SSE-C
- --source-server-side-encryption-algorithm
Possible choices: AES256
Default: “AES256”
- --file-retention-mode
Possible choices: compliance, governance
- --retain-until
- --legal-hold
Possible choices: on, off