diff --git a/.env.example b/.env.example deleted file mode 100644 index 4133de0..0000000 --- a/.env.example +++ /dev/null @@ -1,20 +0,0 @@ -github_token=ghp_xxxxxxxxxxxxxxxx -github_username=USERNAME -github_repository=REPOSITORY -branch_name=main -commit_username="" -commit_email="" - -# Indivdual file syntax: -# Note: script.sh starts its search in $HOME which is /home/{username}/ -# Using below example the script will search for: /home/{username}/printer_data/config/printer.cfg - -#path_printercfg=printer_data/config/printer.cfg - -# Backup folder syntax: -# Note: script.sh starts its search in $HOME which is /home/{username}/ -# Using below example the script will search for: /home/{username}/printer_data/config/* -# The star denotes a wildcard meaning that any and all files in the folder will be selected -path_klipperdata=printer_data/config/* - -backup_folder=config_backup/klipper diff --git a/.github/workflows/close_bot.yml b/.github/workflows/close_bot.yml deleted file mode 100644 index 66742a9..0000000 --- a/.github/workflows/close_bot.yml +++ /dev/null @@ -1,22 +0,0 @@ -name: Close inactive issues -on: - schedule: - - cron: "30 1 * * *" - -jobs: - close-issues: - runs-on: ubuntu-latest - permissions: - issues: write - pull-requests: write - steps: - - uses: actions/stale@v5 - with: - days-before-issue-stale: 30 - days-before-issue-close: 14 - stale-issue-label: "stale" - stale-issue-message: "This issue is stale because it has been open for 30 days with no activity." - close-issue-message: "This issue was closed because it has been inactive for 14 days since being marked as stale." - days-before-pr-stale: -1 - days-before-pr-close: -1 - repo-token: ${{ secrets.GITHUB_TOKEN }} \ No newline at end of file diff --git a/.gitignore b/.gitignore deleted file mode 100644 index 0893759..0000000 --- a/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -.env -secrets.conf \ No newline at end of file diff --git a/README.md b/README.md deleted file mode 100644 index 6f76080..0000000 --- a/README.md +++ /dev/null @@ -1,15 +0,0 @@ -# klipper-backup 💾 -Klipper backup script for manual or automated GitHub backups - -This is a backup script to create manual or automated klipper backups in a github repository. You can [see an example](https://github.com/Staubgeborener/3dprint) of what it looks like in the end. - -## RTFM -I would suggest reading the [wiki](https://github.com/Staubgeborener/klipper-backup/wiki), as this provides detailed step-by-step instructions. - -> [!IMPORTANT] -> If you have already used the script before release 1.0, please read [this wiki article](https://github.com/Staubgeborener/klipper-backup/wiki/migration) before opening an issue! - -## YouTube -The user [Minimal 3DP](https://github.com/minimal3dp) has created a video about the initial setup and use of klipper-backup and made it available on YouTube. This and the wiki should explain many questions in advance. - -[![The Ultimate Guide to Using Klipper Macros to Backup Your Configuration Files](https://img.youtube.com/vi/fR2jIegqv3A/0.jpg)](https://www.youtube.com/watch?v=fR2jIegqv3A "The Ultimate Guide to Using Klipper Macros to Backup Your Configuration Files") \ No newline at end of file diff --git a/script.sh b/script.sh deleted file mode 100755 index a76a2f1..0000000 --- a/script.sh +++ /dev/null @@ -1,70 +0,0 @@ -#!/usr/bin/env bash - -# Check for updates -[ $(git rev-parse HEAD) = $(git ls-remote $(git rev-parse --abbrev-ref @{u} | \ -sed 's/\// /g') | cut -f1) ] && echo -e "Klipper-backup is up to date\n" || echo -e "Klipper-backup is $(tput setaf 1)not$(tput sgr0) up to date, consider making a $(tput setaf 1)git pull$(tput sgr0) to update\n" - -# Set parent directory path -parent_path=$(cd "$(dirname "${BASH_SOURCE[0]}")"; pwd -P) - -# Initialize variables from .env file -source "$parent_path"/.env - -# Change directory to parent path -cd "$parent_path" || exit - -# Check if backup folder exists, create one if it does not -if [ ! -d "$HOME/$backup_folder" ]; then - mkdir -p "$HOME/$backup_folder" -fi - -while IFS= read -r path; do - # Iterate over every file in the path - for file in $HOME/$path; do - # Check if it's a symbolic link - if [ -h "$file" ]; then - echo "Skipping symbolic link: $file" - # Check if file is an extra backup of printer.cfg moonraker/klipper seems to like to make 4-5 of these sometimes no need to back them all up as well. - elif [[ $(basename "$file") =~ ^printer-[0-9]+_[0-9]+\.cfg$ ]]; then - echo "Skipping file: $file" - else - cp -r $file $HOME/$backup_folder/ - fi - done -done < <(grep -v '^#' "$parent_path/.env" | grep 'path_' | sed 's/^.*=//') - -# Add basic readme to backup repo -backup_parent_directory=$(dirname "$backup_folder") -cp "$parent_path"/.gitignore "$HOME/$backup_parent_directory/.gitignore" -echo -e "# klipper-backup 💾 \nKlipper backup script for manual or automated GitHub backups \n\nThis backup is provided by [klipper-backup](https://github.com/Staubgeborener/klipper-backup)." > "$HOME/$backup_parent_directory/README.md" - -# Individual commit message, if no parameter is set, use the current timestamp as commit message -timezone=$(timedatectl | grep "Time zone" | awk '{print $3}') -if [ -n "$1" ]; then - commit_message="$1" -elif [[ "$timezone" == *"America"* ]]; then - commit_message="New backup from $(date +"%m-%d-%y")" -else - commit_message="New backup from $(date +"%d-%m-%y")" -fi - -# Git commands -cd "$HOME/$backup_parent_directory" -# Check if .git exists else init git repo -if [ ! -d ".git" ]; then - mkdir .git - echo "[init] - defaultBranch = $branch_name" >> .git/config #Add desired branch name to config before init - git init - branch=$(git symbolic-ref --short -q HEAD) -else - branch=$(git symbolic-ref --short -q HEAD) -fi - -[[ "$commit_username" != "" ]] && git config user.name "$commit_username" || git config user.name "$(whoami)" -[[ "$commit_email" != "" ]] && git config user.email "$commit_email" || git config user.email "$(whoami)@$(hostname --long)" -git add . -git commit -m "$commit_message" -git push -u https://"$github_token"@github.com/"$github_username"/"$github_repository".git $branch -# Remove klipper folder after backup so that any file deletions can be logged on next backup -rm -rf $HOME/$backup_folder/ \ No newline at end of file