This is the multi-page printable view of this section. Click here to print.

Return to the regular view of this page.

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

TopicDescription
BackupBackup database and files
RestoreRestore from backup or snapshot
CloneClone database or environment
DeployDeploy web application
SSLConfigure SSL certificates
DomainSet up custom domain
ScaleScale resources up or down
MigrateMigrate data from other systems
MonitorSet up alerts and monitoring
UpgradeUpgrade 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:

pig backup create

Backup Database

Full Database Backup

pig backup db --full

Incremental Backup

pig backup db --incremental

Backup Specific Database

pig backup db mydb

Backup Files

Backup User Files

pig backup files

Backup Configurations

pig backup config

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:

TypeLocation
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:

pig restore latest

Restore Database

List Available Backups

pig backup list

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

OptionDescription
--schema-onlyClone structure without data
--no-ownerSkip ownership information
--no-privilegesSkip privilege information
--parallel NUse 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:

pig deploy ./my-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

pig deploy list

View Logs

pig deploy logs my-site

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

pig ssl list

Check Expiration

pig ssl status

Renew Certificates

pig ssl renew

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:

TypeNameValue
A@Your server IP
AwwwYour server IP
CNAMEcode@
CNAMEjupyter@

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

pig domain list

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

Configure Shared Buffers

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:

pig scale status

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

OptionDescription
--schema-onlyMigrate structure only
--data-onlyMigrate data only
--no-ownerSkip ownership
--parallel NParallel jobs
--exclude TABLEExclude 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

DashboardDescription
OverviewSystem overview and health
PostgreSQLDatabase performance metrics
NodeServer resource usage
NginxWeb 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

pig alert list

Add Custom Alert

pig alert add \
  --name "High CPU" \
  --condition "cpu_usage > 80" \
  --duration 5m \
  --severity warning

Default Alerts

AlertConditionSeverity
High CPU> 80% for 5mWarning
High Memory> 90% for 5mWarning
Disk Full> 85%Critical
DB DownConnection failedCritical
Replication Lag> 1sWarning

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:

pig upgrade

Check for Updates

View Current Version

pig version

Check Available Updates

pig upgrade check

Perform Upgrade

Standard Upgrade

pig upgrade --backup

Upgrade to Specific Version

pig upgrade --version 2.5.0

Dry Run

pig upgrade --dry-run

Upgrade PostgreSQL

Check Compatible Versions

pig upgrade pg --list

Upgrade Database Version

pig upgrade pg --version 17

With Full Backup

pig upgrade pg --version 17 --backup

Before Upgrading

  1. Create Backup

    pig backup create --full
    
  2. Check Compatibility

    pig upgrade check --verbose
    
  3. Review Release Notes

    pig upgrade notes
    

Rollback

If upgrade fails:

Restore from Backup

pig restore --backup pre-upgrade

Rollback to Previous Version

pig upgrade rollback

Upgrade History

View upgrade history:

pig 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