Task
Goal-oriented guides for specific operations like backup, restore, deploy.
Task documentation provides goal-oriented guides for specific operations.
How to Use
Each task guide focuses on accomplishing a specific goal:
- Problem-focused: Start with what you want to achieve
- Step-by-step: Clear instructions to follow
- Practical: Real-world scenarios
Topics
| Topic | Description |
|---|
| Backup | Backup database and files |
| Restore | Restore from backup or snapshot |
| Clone | Clone database or environment |
| Deploy | Deploy web application |
| SSL | Configure SSL certificates |
| Domain | Set up custom domain |
| Scale | Scale resources up or down |
| Migrate | Migrate data from other systems |
| Monitor | Set up alerts and monitoring |
| Upgrade | Upgrade Piglet Run |
1 - Backup
Learn how to backup your database and files in Piglet Run.
Overview
Piglet Run provides multiple backup methods to protect your data:
- Database Backup: Full and incremental PostgreSQL backups
- File Backup: User files and configurations
- Snapshot: Complete system state capture
Quick Backup
Create a full backup with a single command:
Backup Database
Full Database Backup
Incremental Backup
pig backup db --incremental
Backup Specific Database
Backup Files
Backup User Files
Backup Configurations
Scheduled Backups
Configure automatic backups in /etc/piglet/backup.yml:
backup:
schedule: "0 2 * * *" # Daily at 2 AM
retention: 7 # Keep 7 days
type: incremental
Backup Storage
Backups are stored in:
| Type | Location |
|---|
| Database | /data/backup/postgres/ |
| Files | /data/backup/files/ |
| Config | /data/backup/config/ |
Next Steps
2 - Restore
Learn how to restore your database and files from backups or snapshots.
Overview
Piglet Run supports multiple restore scenarios:
- Point-in-Time Recovery: Restore to any moment in time
- Full Restore: Restore from a complete backup
- Selective Restore: Restore specific databases or files
Quick Restore
Restore from the latest backup:
Restore Database
List Available Backups
Restore Full Backup
pig restore db --backup 2024-01-15
Point-in-Time Recovery
pig restore db --time "2024-01-15 14:30:00"
Restore Specific Database
pig restore db mydb --backup 2024-01-15
Restore Files
Restore All Files
pig restore files --backup 2024-01-15
Restore Specific Directory
pig restore files /home/dba/projects --backup 2024-01-15
Restore from Snapshot
pig snapshot restore snap-20240115
Verification
After restore, verify data integrity:
pig verify db
pig verify files
Next Steps
3 - Clone
Learn how to clone databases and environments in Piglet Run.
Overview
Cloning allows you to create exact copies of:
- Database: Clone a database for testing or development
- Environment: Clone the entire Piglet Run instance
- Schema Only: Clone structure without data
Quick Clone
Clone a database instantly:
pig clone db mydb mydb_copy
Clone Database
Full Clone
pig clone db production development
Schema Only
pig clone db production development --schema-only
Clone with Data Filter
pig clone db production development --filter "created_at > '2024-01-01'"
Clone Environment
Create Environment Clone
pig clone env --name staging
Clone to Remote Server
pig clone env --target user@remote-server
Clone from Snapshot
pig clone snapshot snap-20240115 --name dev-clone
Clone Options
| Option | Description |
|---|
--schema-only | Clone structure without data |
--no-owner | Skip ownership information |
--no-privileges | Skip privilege information |
--parallel N | Use N parallel jobs |
Use Cases
- Development: Clone production for local development
- Testing: Create isolated test environments
- Analytics: Clone for reporting without impacting production
Next Steps
4 - Deploy
Learn how to deploy web applications on Piglet Run.
Overview
Piglet Run supports deploying various web applications:
- Static Sites: HTML, CSS, JavaScript
- Node.js: Express, Next.js, React
- Python: Flask, Django, FastAPI
- PHP: Laravel, WordPress
Quick Deploy
Deploy a static site:
Deploy Static Site
From Local Directory
pig deploy ./dist --name my-site
From Git Repository
pig deploy https://github.com/user/repo --name my-site
Deploy Node.js Application
Basic Deployment
cd my-node-app
pig deploy --type nodejs
With Custom Port
pig deploy --type nodejs --port 3000
Configuration
Create piglet.yml in your project:
type: nodejs
entry: server.js
port: 3000
env:
NODE_ENV: production
Deploy Python Application
Flask Application
pig deploy --type python --framework flask
Django Application
pig deploy --type python --framework django
Deployment Management
List Deployments
View Logs
Restart Application
pig deploy restart my-site
Remove Deployment
pig deploy remove my-site
Next Steps
5 - SSL
Learn how to configure SSL certificates for secure HTTPS connections.
Overview
Piglet Run supports multiple SSL certificate options:
- Let’s Encrypt: Free automatic certificates
- Self-Signed: For development and testing
- Custom: Bring your own certificates
Quick SSL Setup
Enable SSL with Let’s Encrypt:
pig ssl enable --domain example.com
Let’s Encrypt Certificates
Enable for Domain
pig ssl letsencrypt --domain example.com --email admin@example.com
Multiple Domains
pig ssl letsencrypt --domain example.com --domain www.example.com
Wildcard Certificate
pig ssl letsencrypt --domain "*.example.com" --dns cloudflare
Self-Signed Certificates
Generate Self-Signed
pig ssl self-signed --domain localhost
For Development
pig ssl self-signed --domain dev.local --days 365
Custom Certificates
Install Custom Certificate
pig ssl install --cert /path/to/cert.pem --key /path/to/key.pem
With Certificate Chain
pig ssl install \
--cert /path/to/cert.pem \
--key /path/to/key.pem \
--chain /path/to/chain.pem
Certificate Management
View Certificates
Check Expiration
Renew Certificates
Configuration
SSL settings in /etc/piglet/ssl.yml:
ssl:
provider: letsencrypt
email: admin@example.com
auto_renew: true
renew_days: 30
Next Steps
6 - Domain
Learn how to set up custom domains for your Piglet Run services.
Overview
Configure custom domains for:
- Main Application: Your primary domain
- Subdomains: Service-specific subdomains
- Multiple Domains: Support multiple domains
Quick Setup
Add a custom domain:
pig domain add example.com
DNS Configuration
Required DNS Records
Point your domain to Piglet Run:
| Type | Name | Value |
|---|
| A | @ | Your server IP |
| A | www | Your server IP |
| CNAME | code | @ |
| CNAME | jupyter | @ |
Using Cloudflare
pig domain add example.com --dns cloudflare --api-key YOUR_API_KEY
Add Custom Domain
Primary Domain
pig domain add example.com --primary
Subdomain for Services
pig domain add code.example.com --service vscode
pig domain add jupyter.example.com --service jupyter
Domain Management
List Domains
Remove Domain
pig domain remove old-domain.com
Set Primary
pig domain primary example.com
Configuration
Domain settings in /etc/piglet/domains.yml:
domains:
primary: example.com
aliases:
- www.example.com
services:
vscode: code.example.com
jupyter: jupyter.example.com
grafana: monitor.example.com
Verify Domain
Check domain configuration:
pig domain verify example.com
Next Steps
7 - Scale
Learn how to scale your Piglet Run resources up or down.
Overview
Piglet Run supports scaling:
- Database: Adjust PostgreSQL resources
- Storage: Expand disk capacity
- Services: Scale service resources
Quick Scale
Scale database resources:
pig scale db --cpu 4 --memory 8G
Scale Database
Increase Resources
pig scale db --cpu 4 --memory 16G
Adjust Connection Limits
pig scale db --max-connections 200
pig scale db --shared-buffers 4G
Scale Storage
Expand Disk
pig scale storage --size 100G
Add Storage Volume
pig scale storage add --mount /data/extra --size 50G
Scale Services
VS Code Server
pig scale service vscode --memory 4G
JupyterLab
pig scale service jupyter --memory 8G
Resource Limits
View current resource allocation:
Example output:
Service CPU Memory Storage
--------- ---- ------ -------
PostgreSQL 2 4G 20G
VS Code 1 2G -
Jupyter 1 2G -
Nginx 0.5 512M -
Configuration
Scale settings in /etc/piglet/resources.yml:
resources:
postgres:
cpu: 2
memory: 4G
storage: 20G
vscode:
cpu: 1
memory: 2G
jupyter:
cpu: 1
memory: 2G
Best Practices
- Monitor resource usage before scaling
- Scale gradually to avoid disruption
- Test changes in development first
Next Steps
8 - Migrate
Learn how to migrate data from other systems to Piglet Run.
Overview
Piglet Run supports migration from:
- Other PostgreSQL: Migrate from existing PostgreSQL instances
- MySQL/MariaDB: Convert and migrate from MySQL
- Cloud Databases: AWS RDS, Google Cloud SQL, Azure Database
- Files: Import from SQL dumps or CSV files
Quick Migration
Migrate from another PostgreSQL:
pig migrate postgres://user:pass@source-host/dbname
Migrate from PostgreSQL
Direct Connection
pig migrate pg \
--host source.example.com \
--port 5432 \
--user migrate_user \
--database production
From pg_dump File
pig migrate import backup.sql
Schema Only
pig migrate pg --host source.example.com --schema-only
Migrate from MySQL
Direct Migration
pig migrate mysql \
--host mysql.example.com \
--user migrate_user \
--database myapp
With Type Mapping
pig migrate mysql --host source --type-map mysql-to-pg.yml
Migrate from Cloud
AWS RDS
pig migrate rds \
--instance mydb-instance \
--region us-west-2 \
--profile aws-profile
Google Cloud SQL
pig migrate cloudsql \
--instance myproject:region:instance \
--credentials /path/to/credentials.json
Import Files
SQL Dump
pig migrate import dump.sql --database mydb
CSV Files
pig migrate csv data.csv --table users --database mydb
Multiple CSV Files
pig migrate csv ./data/ --database mydb
Migration Options
| Option | Description |
|---|
--schema-only | Migrate structure only |
--data-only | Migrate data only |
--no-owner | Skip ownership |
--parallel N | Parallel jobs |
--exclude TABLE | Exclude tables |
Verification
Verify migration:
pig migrate verify --source postgres://source/db --target postgres://target/db
Next Steps
9 - Monitor
Learn how to set up alerts and monitoring for your Piglet Run instance.
Overview
Piglet Run includes comprehensive monitoring:
- Grafana Dashboards: Visual monitoring
- Alerting: Configurable alerts
- Metrics: Prometheus-based metrics
- Logs: Centralized logging
Quick Setup
Access monitoring dashboard:
pig monitor open
# Opens Grafana at http://<ip>/ui
Grafana Dashboards
Available Dashboards
| Dashboard | Description |
|---|
| Overview | System overview and health |
| PostgreSQL | Database performance metrics |
| Node | Server resource usage |
| Nginx | Web server statistics |
Access Dashboards
# Default credentials
URL: http://<ip>/ui
User: admin
Password: (shown during install)
Set Up Alerts
Enable Email Alerts
pig alert email --to admin@example.com --smtp smtp.example.com
Enable Slack Alerts
pig alert slack --webhook https://hooks.slack.com/services/...
Enable Webhook Alerts
pig alert webhook --url https://api.example.com/alerts
Alert Rules
View Alert Rules
Add Custom Alert
pig alert add \
--name "High CPU" \
--condition "cpu_usage > 80" \
--duration 5m \
--severity warning
Default Alerts
| Alert | Condition | Severity |
|---|
| High CPU | > 80% for 5m | Warning |
| High Memory | > 90% for 5m | Warning |
| Disk Full | > 85% | Critical |
| DB Down | Connection failed | Critical |
| Replication Lag | > 1s | Warning |
Configuration
Alert configuration in /etc/piglet/alerts.yml:
alerts:
email:
enabled: true
to: admin@example.com
smtp:
host: smtp.example.com
port: 587
slack:
enabled: false
webhook: ""
rules:
- name: high_cpu
expr: cpu_usage > 80
for: 5m
severity: warning
View Logs
# All service logs
pig logs
# Specific service
pig logs postgres
pig logs nginx
Next Steps
10 - Upgrade
Learn how to upgrade your Piglet Run installation.
Overview
Piglet Run upgrades include:
- Minor Updates: Bug fixes and security patches
- Major Upgrades: New features and improvements
- PostgreSQL Upgrades: Database version upgrades
Quick Upgrade
Upgrade to latest version:
Check for Updates
View Current Version
Check Available Updates
Standard Upgrade
Upgrade to Specific Version
pig upgrade --version 2.5.0
Dry Run
Upgrade PostgreSQL
Check Compatible Versions
Upgrade Database Version
pig upgrade pg --version 17
With Full Backup
pig upgrade pg --version 17 --backup
Before Upgrading
Create Backup
Check Compatibility
pig upgrade check --verbose
Review Release Notes
Rollback
If upgrade fails:
Restore from Backup
pig restore --backup pre-upgrade
Rollback to Previous Version
Upgrade History
View upgrade history:
Example output:
Version Date Status
------- ---------- -------
2.5.0 2024-01-15 Current
2.4.1 2024-01-01 Previous
2.4.0 2023-12-15 Archived
Configuration
Upgrade settings in /etc/piglet/upgrade.yml:
upgrade:
auto_backup: true
notify: true
channel: stable # stable, beta, nightly
Next Steps