Skip to content
/ vBackups Public

A robust, secure backup script solution written in V language that creates encrypted, signed, and compressed backups with notifications.

Notifications You must be signed in to change notification settings

Esl1h/vBackups

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

3 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

๐Ÿ”’ V-Backup: Encrypted Backup Script

A robust, secure backup solution written in V language that creates encrypted, signed, and compressed backups with real-time notifications.

1. โœจ Features

๐Ÿ”

GPG Encryption & Signing - All backups are encrypted and digitally signed

๐Ÿ“ฆ

High Compression - Uses pigz for parallel gzip compression

๐Ÿ“ฑ

Real-time Notifications - Sends status updates via ntfy.sh

โšก

Fast & Efficient - Written in V for optimal performance

๐Ÿ›ก๏ธ

Security First - Handles sensitive directories with proper permissions

๐Ÿ“Š

Detailed Reporting - Comprehensive backup statistics and status

๐ŸŽฏ

YAML Configuration - Easy-to-manage configuration file

2. ๐Ÿš€ Quick Start

2.1. Prerequisites

Ensure the following tools are installed on your system:

#
tar pigz gnupg curl

2.2. Installation

  1. Clone or download the script

  2. Make it executable:

    chmod +x vbackup.vsh
  3. Configure your backup settings in backups.yaml

  4. Run the backup:

    ./vbackup.vsh

3. โš™๏ธ Configuration

The script uses a YAML configuration file (backups.yaml) with the following structure:

configs:
  gpg_email: "your-email@example.com"    # (1)
  dest_dir: "/path/to/backup/directory"  # (2)
  ntfy:
    topic: "your-backup-topic"           # (3)
    url: "https://ntfy.sh"               # (4)

backups:
  - title: "DUMMY"                       # (5)
    path: "/tmp"
  - title: "SSH Keys"                    # (6)
    path: "/home/user/.ssh"
  - title: "GPG Keys"
    path: "/home/user/.gnupg"
  - title: "Application Config"
    path: "/home/user/.config/myapp"
  1. Email associated with your GPG key

  2. Directory where encrypted backups will be stored

  3. ntfy.sh topic for notifications

  4. ntfy.sh server URL

  5. Dummy entry - do not remove, used for array initialization

  6. Actual backup entries with title and path

4. ๐Ÿ” GPG Setup

Before running the script, ensure you have a GPG key pair

5. ๐Ÿ“ฑ Notification Setup

The script uses ntfy.sh for real-time notifications

6. ๐Ÿƒโ€โ™‚๏ธ Usage

6.1. Basic Usage

./vbackup.vsh

6.2. Example Output

=== ๐Ÿ”’ BACKUP SCRIPT COM GPG ===
โœ… Chave GPG encontrada

๐Ÿš€ Iniciando backups criptografados...

๐Ÿ“ฆ Processando: SSH Keys
๐Ÿ“‚ Origem: /home/user/.ssh
๐Ÿ’พ Arquivo temporรกrio: /home/user/vBackups/ssh_keys_2025-07-07_18-57-04.tar.gz
๐Ÿ” Usando sudo para diretรณrio sensรญvel
โœ… Backup criado: 2.3 KB
๐Ÿ” Criptografando e assinando com GPG...
โœ… Arquivo criptografado: ssh_keys_2025-07-07_18-57-04.tar.gz.gpg
๐Ÿ—‘๏ธ  Removendo arquivo nรฃo criptografado...
๐Ÿ”’ Backup final: ssh_keys_2025-07-07_18-57-04.tar.gz.gpg (3.1 KB)

=== ๐Ÿ“Š RESUMO FINAL ===
โœ… Backups bem-sucedidos: 3/3
๐Ÿ“ฆ Tamanho total dos backups: 15.7 MB
๐Ÿ”’ Todos os backups foram criptografados e assinados
๐Ÿ“ง Chave GPG usada: your-email@example.com
๐ŸŽ‰ Todos os backups foram concluรญdos com sucesso!

๐Ÿ“ฑ Enviando notificaรงรฃo...

7. ๐Ÿ”ง How It Works

7.1. Backup Process Flow

graph TD
    A[Start] --> B[Check Dependencies]
    B --> C[Load YAML Config]
    C --> D[Verify GPG Key]
    D --> E[Create Destination Directory]
    E --> F[Process Each Backup Item]
    F --> G[Create Compressed Archive]
    G --> H[Encrypt & Sign with GPG]
    H --> I[Remove Unencrypted File]
    I --> J[Update Statistics]
    J --> K{More Items?}
    K -->|Yes| F
    K -->|No| L[Send Notification]
    L --> M[End]
Loading

7.2. File Naming Convention

Backup files follow this naming pattern:

{slugified_title}_{timestamp}.tar.gz.gpg

Example: ssh_keys_2025-07-07_18-57-04.tar.gz.gpg

7.3. Security Features

  • Encryption: All backups are encrypted using GPG with your public key

  • Digital Signing: Files are signed with your private key for authenticity

  • Secure Permissions: Sensitive directories (.ssh, .gnupg) are handled with sudo

  • Cleanup: Unencrypted temporary files are automatically removed

8. ๐Ÿ› ๏ธ Advanced Usage

8.1. Custom Compression

The script uses pigz for parallel compression. You can modify the compression command in the source code:

// Current: tar -I pigz -cf
// Alternative: tar -czf (standard gzip)
// Alternative: tar -I "xz -T0" -cf (xz compression)

8.2. Scheduling with Cron

Add to your crontab for automated backups:

# Daily backup at 2 AM
0 2 * * * /path/to/vbackup.vsh

# Weekly backup on Sundays at 3 AM
0 3 * * 0 /path/to/vbackup.vsh

8.3. Systemd Timer

Create a systemd service and timer for more advanced scheduling:

backup.service
[Unit]
Description=V-Backup Service
After=network.target

[Service]
Type=oneshot
User=your-username
WorkingDirectory=/path/to/script
ExecStart=/path/to/vbackup.vsh
backup.timer
[Unit]
Description=Run V-Backup daily
Requires=backup.service

[Timer]
OnCalendar=daily
Persistent=true

[Install]
WantedBy=timers.target

9. ๐Ÿ› Troubleshooting

9.1. Debug Mode

For debugging, uncomment the debug line in the run_cmd function:

fn run_cmd(cmd string) {
    println('Executando: ${cmd}')  // Uncomment this line
    res := os.execute(cmd)
    // ...
}

10. ๐Ÿ“ File Structure

project/
โ”œโ”€โ”€ vbackup.vsh        # Main backup script
โ”œโ”€โ”€ backups.yaml       # Configuration file
โ””โ”€โ”€ README.adoc        # This documentation

11. ๐Ÿ™ Acknowledgments

  • V Language Team - For the excellent V programming language

  • ntfy.sh - For the simple notification service

  • GPG Project - For robust encryption tools

  • pigz - For parallel compression capabilities


Made with โค๏ธ and V language


About

A robust, secure backup script solution written in V language that creates encrypted, signed, and compressed backups with notifications.

Topics

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages