Metadata-Version: 2.4
Name: s3v
Version: 0.1.1
Summary: Convenient CLI tool to work with versioned (including Object Lock) S3 buckets (recover, undelete, etc.)
Project-URL: Homepage, https://github.com/yaroslaff/s3v
Project-URL: Issues, https://github.com/yaroslaff/s3v/issues
Author-email: Yaroslav Polyakov <yaroslaff@gmail.com>
License: MIT License
        
        Copyright (c) 2026 Yaroslav
        
        Permission is hereby granted, free of charge, to any person obtaining a copy
        of this software and associated documentation files (the "Software"), to deal
        in the Software without restriction, including without limitation the rights
        to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
        copies of the Software, and to permit persons to whom the Software is
        furnished to do so, subject to the following conditions:
        
        The above copyright notice and this permission notice shall be included in all
        copies or substantial portions of the Software.
        
        THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
        IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
        FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
        AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
        LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
        OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
        SOFTWARE.
License-File: LICENSE
Keywords: aws,bucket,cli,object lock,recover,retention,s3,undelete,versioned
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.8
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Requires-Python: >=3.8
Requires-Dist: boto3>=1.28.0
Requires-Dist: botocore>=1.31.0
Description-Content-Type: text/markdown

# s3v
Convinient CLI tool to work with versioned S3 buckets. Like `aws s3` or `aws s3api` but much easier to use.

## Installation
~~~
# recommended
pipx install s3v

# or from git
pipx install git+https://github.com/yaroslaff/s3v
~~~

## Configuration
s3v uses boto3, so configuration is same as for `aws` utility (same `~/.aws/` files or `AWS_` shell variables, and optional `--profile NAME` argument)

## Examples
We upload three versions of same file, each one will overwrite old copy. 


### Upload

```bash
$ echo 1 > test.txt 
$ s3v cp test.txt s3://stg-objectlock/s3v/
$ echo 2 > test.txt 
$ s3v cp test.txt s3://stg-objectlock/s3v/
$ echo 3 > test.txt 
$ s3v cp test.txt s3://stg-objectlock/s3v/
```
You can also give full target name like s3://stg-objectlock/s3v/test.txt. `s3://` prefix is optional (s3 will try to guess what is local file and what is bucket name).


### List
Now, list contents of s3v logical 'folder' (all objects with name starting with `s3v/`). In "ls" we see filename, last modification time, size of latest copy and number of versions in storage. If we give full name of object, ls will list all versions of this object.

```bash
$ s3v ls stg-objectlock/s3v
Listing objects in bucket 'stg-objectlock' with prefix 's3v'
test.txt                                |2026-02-10 16:21:55|              2|   3|

$ s3v ls stg-objectlock/s3v/test.txt
Listing objects in bucket 'stg-objectlock' with prefix 's3v/test.txt'
Objects under prefix 's3v/test.txt':
s3v/test.txt
   by0fQCa9Jl7gFgl8vKEjaDvl8z3CSRnD          2  2026-02-10 16:21:30
   LHK6nA8Ny5YHNh7TOoH94LDinqCH9Czt          2  2026-02-10 16:21:46
   iIGXCsBmEKvBq7DhaP09DIzp3fLO9d1H          2  2026-02-10 16:21:55
```


### Downloading

`s3v cp` will download latest version of file.
```bash
$ s3v cp stg-objectlock/s3v/test.txt .

$ cat test.txt 
3
```

Give `-s VERSION` to download specific version.

```bash
$ s3v cp stg-objectlock/s3v/test.txt . -s by0fQCa9Jl7gFgl8vKEjaDvl8z3CSRnD
  Using version: by0fQCa9Jl7gFgl8vKEjaDvl8z3CSRnD
$ cat test.txt 
1
```


### Delete and undelete

`s3v rm` deletes file. After deletion, `aws s3 ls` do not list file, but `s3v ls` still shows it with `[DEL]` tag.

```bash
$ s3v rm stg-objectlock/s3v/test.txt
$ aws s3 ls stg-objectlock/s3v/
$ s3v ls stg-objectlock/s3v/
Listing objects in bucket 'stg-objectlock' with prefix 's3v/'
test.txt                                |2026-02-10 16:35:00|              2|   4| [DEL]
```

If we will see versions for file, we will see special delete marker on S3 (which makes file to be logically 'deleted').
```bash
 $ s3v ls stg-objectlock/s3v/test.txt
Listing objects in bucket 'stg-objectlock' with prefix 's3v/test.txt'
# Fetching version metadata for bucket: stg-objectlock...
# Fetched metadata for 215 versions from 153 object(s) in bucket 'stg-objectlock'
Objects under prefix 's3v/test.txt':
s3v/test.txt [deleted]
   by0fQCa9Jl7gFgl8vKEjaDvl8z3CSRnD          2  2026-02-10 16:21:30
   LHK6nA8Ny5YHNh7TOoH94LDinqCH9Czt          2  2026-02-10 16:21:46
   iIGXCsBmEKvBq7DhaP09DIzp3fLO9d1H          2  2026-02-10 16:21:55
   odaXkvFlMoAWwDu_q.K3esuYdHjUpgMg  [DELETED]  2026-02-10 16:40:33
```

`s3v unrm` will remove "delete marker" and file (latest version) will be available again.
```bash
$ s3v unrm stg-objectlock/s3v/test.txt

$ s3v ls stg-objectlock/s3v/
Listing objects in bucket 'stg-objectlock' with prefix 's3v/'
test.txt                                |2026-02-10 16:35:00|              2|   3|
```

### Restore specific version
To recover specific version of file (make it to be current) use `s3v recover` (or just `s3v r`). Let's recover first version of file.

```bash
$ s3v recover stg-objectlock/s3v/test.txt . -s by0fQCa9Jl7gFgl8vKEjaDvl8z3CSRnD
Successfully recovered version by0fQCa9Jl7gFgl8vKEjaDvl8z3CSRnD as current version of s3://stg-objectlock/s3v/test.txt

$ s3v cp stg-objectlock/s3v/test.txt . 
$ cat test.txt 
1
```

