Files
Move-PeerTube-video-storage…/README.md
2025-10-10 07:20:02 +02:00

118 lines
3.3 KiB
Markdown
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# Move PeerTube video storage to Hetzner S3
Hi everyone,
after a few failed attempts with other S3 providers like **iDrive** and **Backblaze**,
I tried **Hetzner Object Storage (S3)** — where we also host our servers.
Heres my working setup and migration process — maybe it helps someone.
Everything works great: Ive successfully moved **~240 GB** of videos, all without issues.
## 1⃣ Create your S3 bucket(s)
- Region: **fsn1 (Falkenstein)**
- Visibility: **Public (read)**
- Block Public Access: **off**
Example buckets:
- `peertube-1`
- `peertube-2` (optional, for another instance)
## 2⃣ Set CORS configuration
Create a file called `example-cors.xml`:
```json
<CORSConfiguration>
<CORSRule>
<AllowedHeader>*</AllowedHeader>
<AllowedMethod>GET</AllowedMethod>
<AllowedMethod>HEAD</AllowedMethod>
<AllowedOrigin>*</AllowedOrigin>
</CORSRule>
</CORSConfiguration>
```
Apply it to your bucket(s):
```json
s3cmd --config=/dev/null --no-check-certificate \
--access_key=YOUR_ACCESS_KEY \
--secret_key=YOUR_SECRET_KEY \
--host=fsn1.your-objectstorage.com \
--host-bucket="%(bucket)s.fsn1.your-objectstorage.com" \
setcors example-cors.xml s3://peertube-1
```
Check it:
```json
s3cmd --config=/dev/null --no-check-certificate \
--access_key=YOUR_ACCESS_KEY \
--secret_key=YOUR_SECRET_KEY \
--host=fsn1.your-objectstorage.com \
--host-bucket="%(bucket)s.fsn1.your-objectstorage.com" \
info s3://peertube-1 | grep CORS -A1
```
You should see:
```json
CORS: <CORSConfiguration ...><AllowedOrigin>*</AllowedOrigin>...</CORSConfiguration>
```
## 3⃣ Edit PeerTube configuration
Open `/app/data/production.yaml` and add or modify this block:
```yaml
object_storage:
enabled: true
endpoint: 'https://fsn1.your-objectstorage.com'
region: 'eu-central'
credentials:
access_key_id: 'YOUR_ACCESS_KEY'
secret_access_key: 'YOUR_SECRET_KEY'
videos:
bucket_name: 'peertube-1'
prefix: 'videos/'
base_url: 'https://peertube-1.fsn1.your-objectstorage.com'
upload_acl: 'public-read'
streaming_playlists:
bucket_name: 'peertube-1'
prefix: 'hls/'
base_url: 'https://peertube-1.fsn1.your-objectstorage.com'
upload_acl: 'public-read'
previews:
bucket_name: 'peertube-1'
prefix: 'previews/'
base_url: 'https://peertube-1.fsn1.your-objectstorage.com'
upload_acl: 'public-read'
thumbnails:
bucket_name: 'peertube-1'
prefix: 'thumbnails/'
base_url: 'https://peertube-1.fsn1.your-objectstorage.com'
upload_acl: 'public-read'
captions:
bucket_name: 'peertube-1'
prefix: 'captions/'
base_url: 'https://peertube-1.fsn1.your-objectstorage.com'
upload_acl: 'public-read'
```
Save and restart PeerTube.
## 4⃣ Move videos to S3
From the Cloudron Web Terminal:
```bash
cd /app/code/server
```
```
gosu cloudron:cloudron npm run create-move-video-storage-job -- --to-object-storage
```
This creates jobs that migrate all videos to your S3 bucket. Progress can be monitored in Cloudron → App → Logs.
## 5⃣ Verify
Check the directory size before/after:
```bash
du -sh /app/data/storage
du -sh /app/data/storage/* | sort -h
```
When migration finishes, most data (videos, HLS, previews) should move to S3. Local disk usage should drop to a few GB.
**Tested setup**
- PeerTube 7.3.0
- Cloudron v8.3.2
- Hetzner Object Storage (fsn1)