commit 797024ff935be2c349237ada60c39eaaaaf747cb Author: eetnaviation Date: Fri Jun 27 14:16:56 2025 +0300 Initial commit diff --git a/Backup/automaticBackup.sh b/Backup/automaticBackup.sh new file mode 100644 index 0000000..e6172c9 --- /dev/null +++ b/Backup/automaticBackup.sh @@ -0,0 +1,71 @@ +# ============================================================================= +# automaticBackup.sh +# +# Automatic, configurable, optional-SFTP backup script. +# +# Copyright (c) 2025 VELENDEU, eetnaviation +# +# https://velend.eu/ +# https://git.velend.eu/eetnaviation/shscripts +# +# All rights reserved unless otherwise stated. +# +# Permission is hereby denied to copy, modify, distribute, sublicense, +# or sell copies of this software without explicit prior written consent. +# +# All dependency trademarks and names if included are subject to copyright +# of their respective owners. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +# THE SOFTWARE. +# ============================================================================= + +#!/bin/bash + +##################### BEGIN USER CONFIGURABLE PART ##################### + +BACKUP_PATHS="" # Choose directories you want to backup separated by spaces. Example: Backup /home and /var/www would be "/home /var/www" +BACKUP_DESTINATION="/backup" # Default /backup, changes the backup destination. This is where your local backups are stored. + +ENABLE_SFTP_BACKUP="false" # Default false, enables/disables SFTP backup sync. +DELETE_LOCAL_BACKUP_UPON_SUCCESSFUL_SFTP_UPLOAD="true" # Default true, enables/disables deleting local backup after successful upload to sftp server. +SFTP_USER="" # Enter your SFTP user here. +SFTP_HOST="" # Enter your SFTP server IP or domain name here. +SFTP_PASSWORD="" # Enter your SFTP user password here. +SFTP_REMOTE_DIRECTORY="" # Enter your SFTP remote directory here. + +###################### END USER CONFIGURABLE PART ###################### + +DATE=$(date +%Y-%m-%d) +HOSTNAME=$(HOSTNAME -s) +ARCHIVE_FILE_NAME="$HOSTNAME-$DATE.tgz" +LOCAL_FILE="$BACKUP_DESTINATION/$ARCHIVE_FILE_NAME" + +# Local backup part. +echo "Starting local backup..." +mkdir -p "$BACKUP_DESTINATION" +tar czf "$BACKUP_DESTINATION/$ARCHIVE_FILE_NAME" $BACKUP_PATHS +echo "Finished local backup!" +ls -aril "$BACKUP_DESTINATION" + +# If enabled sync backup to SFTP server. +if [ "$ENABLE_SFTP_BACKUP" = "true" ]; then + lftp -u "$SFTP_USER,$SFTP_PASSWORD" sftp://$SFTP_HOST < $insidePort, Here are your current IpTables mappings:" + # Display all mappings + iptables -t nat -L -v -n + else + echo "Invalid input, must be numeric ports." + fi +done diff --git a/README.md b/README.md new file mode 100644 index 0000000..f9ddcf8 --- /dev/null +++ b/README.md @@ -0,0 +1,15 @@ +# shscripts +A useful collection of my bash/sh scripts. + +## Script collection breakdown +Here is a breakdown of the collection. +### Backup scripts +Scripts to simplify backup procedures. +[automaticBackup.sh](https://git.velend.eu/eetnaviation/shscripts/src/branch/main/Backup/automaticBackup.sh) - Automatic, configurable, optional-SFTP backup script. +### IpTables scripts +Scripts to configure different IpTables aspects. +[easyIpTables.sh](https://git.velend.eu/eetnaviation/shscripts/src/branch/main/IpTables/easyIpTables.sh) - Allows you to easily set IpTables mappings for incoming and outgoing ports. +[autoIpTables.sh](https://git.velend.eu/eetnaviation/shscripts/src/branch/main/IpTables/autoIpTables.sh) - Setup multiple IpTables incoming and outgoing port mappings for easy setup. +### Git scripts +Scripts to automate or simplify procedures with GIT. +[addGitSSHKey.sh](https://git.velend.eu/eetnaviation/shscripts/src/branch/main/Git/addGitSSHKey.sh) - Simple script to add your GIT ssh key on startup or when executed. \ No newline at end of file