ptctools 0.1.1__py3-none-any.whl → 0.2.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,131 +0,0 @@
1
- Metadata-Version: 2.4
2
- Name: ptctools
3
- Version: 0.1.1
4
- Summary: Portainer Client Tools - CLI for managing Portainer from client
5
- License-File: LICENSE
6
- Requires-Python: >=3.10
7
- Requires-Dist: click>=8.0
8
- Requires-Dist: docker==7.1.0
9
- Requires-Dist: pydantic>=2.12.5
10
- Requires-Dist: python-dateutil>=2.9.0.post0
11
- Provides-Extra: dev
12
- Requires-Dist: pytest>=8.0; extra == 'dev'
13
- Description-Content-Type: text/markdown
14
-
15
- # ptctools - Portainer Client Tools
16
-
17
- CLI for managing Portainer stacks, volume backups, and database operations.
18
-
19
- > **Note:** Only tested on Portainer 2.33.6
20
-
21
- ## Installation
22
-
23
- ```bash
24
- # From Git repository
25
- uv tool install git+https://github.com/tamntlib/ptctools.git
26
- # or
27
- uv tool install ptctools --from git+https://github.com/tamntlib/ptctools.git
28
-
29
- # From local path
30
- uv tool install openapi-generator-cli==7.19.0
31
- openapi-generator-cli generate \
32
- -i portainer_openapi.yml \
33
- -g python \
34
- -o ./src/ptctools/portainer_client \
35
- --skip-validate-spec \
36
- --additional-properties=generateSourceCodeOnly=true
37
- uv tool install . --no-cache --reinstall
38
- ```
39
-
40
- ## Usage
41
-
42
- ```bash
43
- export PORTAINER_URL=https://portainer.example.com
44
- export PORTAINER_ACCESS_TOKEN=your-api-key
45
- export S3_ACCESS_KEY=your-s3-key
46
- export S3_SECRET_KEY=your-s3-secret
47
- export S3_ENDPOINT=https://s3.<region>.amazonaws.com
48
-
49
- # Stack deployment
50
- ptctools stack deploy -u $PORTAINER_URL -n mystack -f compose.yaml
51
-
52
- # Volume backup/restore (uses Duplicati)
53
- ptctools volume backup -u $PORTAINER_URL -v vol1,vol2 -o s3://mybucket
54
- ptctools volume restore -u $PORTAINER_URL -i s3://mybucket/vol1 # volume name derived from URI path
55
- ptctools volume restore -u $PORTAINER_URL -v vol1 -i s3://mybucket/vol1 # explicit volume name
56
-
57
- # Volume copy (raw copy using mc/busybox)
58
- ptctools volume cp -u $PORTAINER_URL source dest # volume to volume
59
- ptctools volume cp -u $PORTAINER_URL s3://mybucket/path dest # S3 to volume
60
- ptctools volume cp -u $PORTAINER_URL source s3://mybucket/path # volume to S3
61
-
62
- # Volume management
63
- ptctools volume rm -u $PORTAINER_URL myvolume # remove volume (with confirmation)
64
- ptctools volume rm -u $PORTAINER_URL -y myvolume # remove without confirmation
65
- ptctools volume rename -u $PORTAINER_URL old_name new_name # rename volume (copy + delete)
66
-
67
- # Database backup/restore (uses minio/mc for S3)
68
- ptctools db backup -u $PORTAINER_URL -c container_id -v db_data \
69
- --db-user postgres --db-name mydb -o backup.sql.gz
70
- ptctools db backup -u $PORTAINER_URL -c container_id -v db_data \
71
- --db-user postgres --db-name mydb -o s3://mybucket/backups/db.sql.gz
72
-
73
- ptctools db restore -u $PORTAINER_URL -c container_id -v db_data \
74
- --db-user postgres --db-name mydb -i backup.sql.gz
75
- ptctools db restore -u $PORTAINER_URL -c container_id -v db_data \
76
- --db-user postgres --db-name mydb -i s3://mybucket/backups/db.sql.gz
77
-
78
- # Config management
79
- # Create config from inline data
80
- ptctools config set -u $PORTAINER_URL -n my-config -d "config content"
81
- ptctools config set -u $PORTAINER_URL -n nginx.conf -f ./nginx.conf
82
- ptctools config set -u $PORTAINER_URL -n my-config -d "new content" --force
83
- ptctools config list -u $PORTAINER_URL
84
- ptctools config get -u $PORTAINER_URL -n my-config
85
- ptctools config delete -u $PORTAINER_URL -n my-config
86
-
87
- # Utils - local Duplicati operations
88
- ptctools utils backup --input ./data --output s3://backups/mydata
89
- ptctools utils restore --input s3://backups/mydata --output ./restored
90
-
91
- ```
92
-
93
- ## Environment Variables
94
-
95
- - `PORTAINER_ACCESS_TOKEN` - Portainer API key (required)
96
- - `S3_ACCESS_KEY` / `S3_SECRET_KEY` - S3 credentials (for backup commands)
97
- - `S3_ENDPOINT` - S3/MinIO endpoint URL
98
- - `DUPLICATI_PASSPHRASE` - Backup encryption passphrase (optional, for volume backups)
99
-
100
- ## Commands
101
-
102
- ### `ptctools stack deploy`
103
- Deploy or update a Docker stack in Portainer.
104
-
105
- ### `ptctools volume backup/restore`
106
-
107
- - **backup**: Backup multiple Docker volumes (comma-separated) to S3 using Duplicati container.
108
- - **restore**: Restore a single Docker volume from S3. Volume name can be specified via `--volume` or derived from the input URI path.
109
-
110
- ### `ptctools volume cp`
111
- Copy data between volumes and S3 (raw file copy).
112
- - **volume to volume**: Uses `busybox` with `cp -a`
113
- - **S3 to volume**: Uses `minio/mc` to download files
114
- - **volume to S3**: Uses `minio/mc` to upload files
115
-
116
- ### `ptctools volume rm`
117
- Remove a Docker volume. Use `-y` to skip confirmation, `-f` to force removal.
118
-
119
- ### `ptctools volume rename`
120
- Rename a volume by copying data to a new volume and deleting the original.
121
-
122
- ### `ptctools db backup/restore`
123
- Backup/restore PostgreSQL database. Supports both local files and S3 URIs.
124
- - Uses `pg_dump`/`psql` for database operations
125
- - Uses `minio/mc` container for S3 transfers
126
-
127
- ### `ptctools utils backup/restore`
128
- Local backup/restore operations using Duplicati CLI (docker or local).
129
-
130
- ### `ptctools config set/get/list/delete`
131
- Manage Docker Swarm configs via Portainer API.