1_minio-console-commands.sh
                        
                             · 405 B · Bash
                        
                    
                    
                      
                        Raw
                      
                    
                      
                    
                        
                          
                        
                    
                    
                
                
                
            # Add new S3 user to Minio
mc admin user add thasystems "s3-username" "s3-password"
# Create and attach S3 policy to user in Minio
mc admin policy create thasystems restic_sample_policy /tmp/restic_policy.json
mc admin policy attach thasystems "restic_sample_policy" --user "s3-username"
# Create new bucket 'resticsample' and ignore if it already exists
mc mb --ignore-existing thasystems/resticsample
                | 1 | # Add new S3 user to Minio | 
| 2 | mc admin user add thasystems "s3-username" "s3-password" | 
| 3 | |
| 4 | # Create and attach S3 policy to user in Minio | 
| 5 | mc admin policy create thasystems restic_sample_policy /tmp/restic_policy.json | 
| 6 | mc admin policy attach thasystems "restic_sample_policy" --user "s3-username" | 
| 7 | |
| 8 | # Create new bucket 'resticsample' and ignore if it already exists | 
| 9 | mc mb --ignore-existing thasystems/resticsample | 
| 10 | 
                    
                        
                        restic-backup-and-restore.sh
                        
                             · 942 B · Bash
                        
                    
                    
                      
                        Raw
                      
                    
                      
                    
                        
                          
                        
                    
                    
                
                
                
            # (environment) variables you need
export AWS_ACCESS_KEY_ID="s3-username"
export AWS_SECRET_ACCESS_KEY="s3-password"
export RESTIC_PASSWORD="password"
# initialize Minio Backup Repository
restic -r s3:https://s3.domain.tld/resticsample init
# Export PostGreSQL Dump of Zammad database
sudo -u postgres pg_dump --dbname zammad --no-privileges --no-owner >> /tmp/zammad.psql
# Backup complete Zammad directory with database dump
restic -r s3:https://s3.domain.tld/resticsample migrate
restic --no-scan --read-concurrency=25 --pack-size=128 --compression off -r s3:https://s3.domain.tld/resticsample backup --exclude "/opt/zammad/tmp/*" /opt/zammad/ /tmp/zammad.psql
# Restore a PostGreSQL Dump from Repo
restic -r s3:https://s3.domain.tld/resticsample dump latest '/tmp/zammad.psql' | sudo -u postgres psql zammad
# Restore Zammad filesystem
restic -r s3:https://s3.domain.tld/resticsample restore latest --include /opt/zammad/ --target /
                | 1 | # (environment) variables you need | 
| 2 | export AWS_ACCESS_KEY_ID="s3-username" | 
| 3 | export AWS_SECRET_ACCESS_KEY="s3-password" | 
| 4 | export RESTIC_PASSWORD="password" | 
| 5 | |
| 6 | # initialize Minio Backup Repository | 
| 7 | restic -r s3:https://s3.domain.tld/resticsample init | 
| 8 | |
| 9 | # Export PostGreSQL Dump of Zammad database | 
| 10 | sudo -u postgres pg_dump --dbname zammad --no-privileges --no-owner >> /tmp/zammad.psql | 
| 11 | |
| 12 | # Backup complete Zammad directory with database dump | 
| 13 | restic -r s3:https://s3.domain.tld/resticsample migrate | 
| 14 | restic --no-scan --read-concurrency=25 --pack-size=128 --compression off -r s3:https://s3.domain.tld/resticsample backup --exclude "/opt/zammad/tmp/*" /opt/zammad/ /tmp/zammad.psql | 
| 15 | |
| 16 | # Restore a PostGreSQL Dump from Repo | 
| 17 | restic -r s3:https://s3.domain.tld/resticsample dump latest '/tmp/zammad.psql' | sudo -u postgres psql zammad | 
| 18 | |
| 19 | # Restore Zammad filesystem | 
| 20 | restic -r s3:https://s3.domain.tld/resticsample restore latest --include /opt/zammad/ --target / | 
| 21 | 
                    
                        
                        restic-repository-management.sh
                        
                             · 1.3 KiB · Bash
                        
                    
                    
                      
                        Raw
                      
                    
                      
                    
                        
                          
                        
                    
                    
                
                
                
            # List all snapshots of the backup repository
restic -r s3:https://s3.domain.tld/resticsample
# List files in your backup
restic -r s3:https://s3.domain.tld/resticsample ls --long latest /opt/zammad/config/
# Mount your backup for easier search of files all over all snapshots
# (technically works for restore too, but slower)
restic -r s3:https://s3.domain.tld/resticsample mount /mnt/
# Apply snapshot hold policy and remove snapshots older than defined rules
restic -r s3:https://s3.domain.tld/resticsample forget --group-by '' --keep-hourly 1 --keep-daily 14 --prune
# Read 25% of your backup to verify its integrity
restic -r s3:https://s3.domain.tld/resticsample check --read-data-subset=25%
# Do it on 100% of your backup
restic -r s3:https://s3.domain.tld/resticsample check
# Change the current password of a repository key
restic -r s3:https://s3.domain.tld/resticsample key passwd
# Add further keys to your repository
restic -r s3:https://s3.domain.tld/resticsample key add
# List all configured keys
restic -r s3:https://s3.domain.tld/resticsample key list
# Remove a certain key ID (from previous list)
restic -r s3:https://s3.domain.tld/resticsample key remove <id>
# Unlock a locked backup repository
restic -r s3:https://s3.domain.tld/resticsample unlock
                | 1 | # List all snapshots of the backup repository | 
| 2 | restic -r s3:https://s3.domain.tld/resticsample | 
| 3 | |
| 4 | # List files in your backup | 
| 5 | restic -r s3:https://s3.domain.tld/resticsample ls --long latest /opt/zammad/config/ | 
| 6 | |
| 7 | # Mount your backup for easier search of files all over all snapshots | 
| 8 | # (technically works for restore too, but slower) | 
| 9 | restic -r s3:https://s3.domain.tld/resticsample mount /mnt/ | 
| 10 | |
| 11 | # Apply snapshot hold policy and remove snapshots older than defined rules | 
| 12 | restic -r s3:https://s3.domain.tld/resticsample forget --group-by '' --keep-hourly 1 --keep-daily 14 --prune | 
| 13 | |
| 14 | # Read 25% of your backup to verify its integrity | 
| 15 | restic -r s3:https://s3.domain.tld/resticsample check --read-data-subset=25% | 
| 16 | # Do it on 100% of your backup | 
| 17 | restic -r s3:https://s3.domain.tld/resticsample check | 
| 18 | |
| 19 | # Change the current password of a repository key | 
| 20 | restic -r s3:https://s3.domain.tld/resticsample key passwd | 
| 21 | |
| 22 | # Add further keys to your repository | 
| 23 | restic -r s3:https://s3.domain.tld/resticsample key add | 
| 24 | |
| 25 | # List all configured keys | 
| 26 | restic -r s3:https://s3.domain.tld/resticsample key list | 
| 27 | |
| 28 | # Remove a certain key ID (from previous list) | 
| 29 | restic -r s3:https://s3.domain.tld/resticsample key remove <id> | 
| 30 | |
| 31 | # Unlock a locked backup repository | 
| 32 | restic -r s3:https://s3.domain.tld/resticsample unlock | 
| 33 | 
                    
                        
                        restic_policy.json
                        
                             · 170 B · Binary
                        
                    
                    
                      
                        Raw
                      
                    
                        
                          
                        
                    
                    
                
                
                
                
                    This file can't be rendered. View the full file.