diff --git a/bin/arm_dir_files.bat b/bin/arm_dir_files.bat new file mode 100644 index 0000000..77ed42f --- /dev/null +++ b/bin/arm_dir_files.bat @@ -0,0 +1,13 @@ +@echo off +:: arm directory args1 +for /F "delims=" %%f in ('dir /b /s %1') do ( + :: skip folders + if not exist "%%~f\" ( + :: skip files without .disarmed extension + if ".disarmed" == "%%~xf" ( + move "%%~f" "%%~dpnf" + echo "%%~f" renamed to "%%~dpnf" + ) + ) +) +@pause diff --git a/bin/aws-list-deep-glacier-files b/bin/aws-list-deep-glacier-files new file mode 100644 index 0000000..7da7f6f --- /dev/null +++ b/bin/aws-list-deep-glacier-files @@ -0,0 +1,46 @@ +#!/usr/bin/env bash + +if which tput >/dev/null 2>&1; then + ncolors=$(tput colors) +fi +if [ -t 1 ] && [ -n "$ncolors" ] && [ "$ncolors" -ge 8 ]; then + RED="$(tput setaf 1)" + GREEN="$(tput setaf 2)" + YELLOW="$(tput setaf 3)" + BLUE="$(tput setaf 4)" + MAGENTA="$(tput setaf 5)" + CYAN="$(tput setaf 6)" + BOLD="$(tput bold)" + NORMAL="$(tput sgr0)" +else + RED="" + GREEN="" + YELLOW="" + BLUE="" + MAGENTA="" + CYAN="" + BOLD="" + NORMAL="" +fi + +error() { + printf "${BOLD}${RED}$1${NORMAL}\n" +} + +abort() { + error "\nAborting...\n" + exit 1 +} + +set -e + +bucket="$1" +path="$2" +output_file="$3" + +if [[ $bucket == "" || $path == "" || $output_file == "" ]]; then + error "Usage: aws-list-deep-glacier-files " + exit 1 +fi + +aws s3api list-objects-v2 --bucket $bucket --prefix $path --query "Contents[?StorageClass=='DEEP_ARCHIVE']" --output text | LC_ALL=C awk '{print substr($0, index($0, $2))}' | awk '{NF-=3};3' > "$output_file" diff --git a/bin/aws-restore-deep-glacier-folder b/bin/aws-restore-deep-glacier-folder new file mode 100644 index 0000000..e3d0bdc --- /dev/null +++ b/bin/aws-restore-deep-glacier-folder @@ -0,0 +1,69 @@ +#!/usr/bin/env bash + +# +# Restores all files/folders inside a particular bucket path, +# e.g. aws-restore-deep-glacier-folder mcampagnaro-deep-glacier images restored_images +# will restore all files inside the images folder of the mcampagnaro-deep-glacier bucket, saving +# temp restoration data in the local "restored_images" directory. +# + +if which tput >/dev/null 2>&1; then + ncolors=$(tput colors) +fi +if [ -t 1 ] && [ -n "$ncolors" ] && [ "$ncolors" -ge 8 ]; then + RED="$(tput setaf 1)" + GREEN="$(tput setaf 2)" + YELLOW="$(tput setaf 3)" + BLUE="$(tput setaf 4)" + MAGENTA="$(tput setaf 5)" + CYAN="$(tput setaf 6)" + BOLD="$(tput bold)" + NORMAL="$(tput sgr0)" +else + RED="" + GREEN="" + YELLOW="" + BLUE="" + MAGENTA="" + CYAN="" + BOLD="" + NORMAL="" +fi + +error() { + printf "${BOLD}${RED}$1${NORMAL}\n" +} + +abort() { + error "\nAborting...\n" + exit 1 +} + +set -e + +bucket="$1" +path="$2" +temp_dir="$3" +number_of_objects_per_file=100 +days_available=7 +restore_tier="Bulk" # Can also be "Standard" + +if [[ $bucket == "" || $path == "" || $temp_dir == "" ]]; then + error "Usage: aws-restore-deep-glacier-folder " + exit 1 +fi + +printf "${BOLD}Restoring ${GREEN}$bucket:$path${NORMAL}${BOLD} with local temp folder ${GREEN}$temp_dir${NORMAL}\n" + +mkdir -p "$temp_dir" +pushd "$temp_dir" &>/dev/null + +aws s3api list-objects-v2 --bucket $bucket --prefix $path --query "Contents[?StorageClass=='DEEP_ARCHIVE']" --output text | LC_ALL=C awk '{print substr($0, index($0, $2))}' | awk '{NF-=3};3' > all_objects_list.txt + +# Generate the main script that will kick off the restoration. +printf "while read x; do\n printf \"aws s3api restore-object --restore-request '{\\\\\"Days\\\\\":$days_available,\\\\\"GlacierJobParameters\\\\\":{\\\\\"Tier\\\\\":\\\\\"$restore_tier\\\\\"}}' --bucket $bucket --key \\\\\"\$x\\\\\"\\\\n\"\n aws s3api restore-object --restore-request \"{\\\\\"Days\\\\\":$days_available,\\\\\"GlacierJobParameters\\\\\":{\\\\\"Tier\\\\\":\\\\\"$restore_tier\\\\\"}}\" --bucket $bucket --key \"\$x\"\ndone < all_objects_list.txt\nprintf \"\\\\nDone! You can now delete this folder.\\\\n\"\n" > run.sh +chmod +x run.sh + +printf "${BOLD}You can now run ${GREEN}$temp_dir/run.sh${NORMAL}${BOLD} to start the restoration process.\n" + +popd &>/dev/null diff --git a/bin/backup-svn-repo b/bin/backup-svn-repo new file mode 100644 index 0000000..e9b11a1 --- /dev/null +++ b/bin/backup-svn-repo @@ -0,0 +1,58 @@ +#!/usr/bin/env bash + +if which tput >/dev/null 2>&1; then + ncolors=$(tput colors) +fi +if [ -t 1 ] && [ -n "$ncolors" ] && [ "$ncolors" -ge 8 ]; then + RED="$(tput setaf 1)" + GREEN="$(tput setaf 2)" + YELLOW="$(tput setaf 3)" + BLUE="$(tput setaf 4)" + MAGENTA="$(tput setaf 5)" + CYAN="$(tput setaf 6)" + BOLD="$(tput bold)" + NORMAL="$(tput sgr0)" +else + RED="" + GREEN="" + YELLOW="" + BLUE="" + MAGENTA="" + CYAN="" + BOLD="" + NORMAL="" +fi + +error() { + printf "${BOLD}${RED}$1${NORMAL}\n" +} + +set -e + +repo_path="$1" +output_path="$2" + +if [[ $repo_path == "" || $output_path == "" ]]; then + error "Missing args: " + exit 1 +fi + +if [[ ! -d $repo_path ]]; then + error "Repo directory '$repo_path' doesn't exist." + exit 1 +fi + +mkdir -p $output_path + +now=$(echo $(date '+%Y-%m-%d-%H-%M-%S')) +backup_path="$output_path/${now}_jellypixel_repos.dump.gz" + +printf "${BOLD}${YELLOW}Backing up '$repo_path' to '$backup_path'\n" +printf "Proceed? (1|y)\n> ${NORMAL}" + +read -e proceed +if [[ ! ($proceed == "1" || $proceed == "y") ]]; then + exit 1 +fi + +svnadmin.exe dump $repo_path | gzip -9 > $backup_path diff --git a/bin/disarm_dir_files.bat b/bin/disarm_dir_files.bat new file mode 100644 index 0000000..fd18715 --- /dev/null +++ b/bin/disarm_dir_files.bat @@ -0,0 +1,13 @@ +@echo off +:: disarm directory args1 +for /F "delims=" %%f in ('dir /b /s %1') do ( + :: skip folders + if not exist "%%~f\" ( + :: skip .disarmed extension + if not ".disarmed" == "%%~xf" ( + move "%%~f" "%%~f.disarmed" + echo "%%~f" renamed to "%%~f.disarmed" + ) + ) +) +@pause diff --git a/bin/restore-svn-backup b/bin/restore-svn-backup new file mode 100644 index 0000000..c42d5fa --- /dev/null +++ b/bin/restore-svn-backup @@ -0,0 +1,62 @@ +#!/usr/bin/env bash + +# +# Loads an SVN snapshot into an existing repository. This will replace all existing data in that repo. +# + +if which tput >/dev/null 2>&1; then + ncolors=$(tput colors) +fi +if [ -t 1 ] && [ -n "$ncolors" ] && [ "$ncolors" -ge 8 ]; then + RED="$(tput setaf 1)" + GREEN="$(tput setaf 2)" + YELLOW="$(tput setaf 3)" + BLUE="$(tput setaf 4)" + MAGENTA="$(tput setaf 5)" + CYAN="$(tput setaf 6)" + BOLD="$(tput bold)" + NORMAL="$(tput sgr0)" +else + RED="" + GREEN="" + YELLOW="" + BLUE="" + MAGENTA="" + CYAN="" + BOLD="" + NORMAL="" +fi + +error() { + printf "${BOLD}${RED}$1${NORMAL}\n" +} + +set -e + +backup_path="$1" +repo_path="$2" + +if [[ ($backup_path == "") || ($repo_path == "") ]]; then + error "Missing args: " + exit 1 +fi + +if [[ ! -f $backup_path ]]; then + error "Backup file '$backup_path' doesn't exist.\n" + exit 1 +fi + +if [[ ! -d $repo_path ]]; then + error "SVN repo '$repo_path' doesn't exist.\n" + exit 1 +fi + +printf "${BOLD}${YELLOW}Loading backup '$backup_path' to '$repo_path'\n" +printf "This will replace all existing data in the repo.\n" +printf "Proceed? (1|y)\n> ${NORMAL}" +read -e proceed +if [[ ! ($proceed == "1" || $proceed == "y") ]]; then + exit 1 +fi + +gunzip -c $backup_path | svnadmin load $repo_path diff --git a/windows/readme.md b/windows/readme.md index 49c8023..23a1e2e 100644 --- a/windows/readme.md +++ b/windows/readme.md @@ -122,7 +122,7 @@ processor time and is generally useless. tools/packages). * Open `C:\msys64\mingw64.exe` * Run `pacman -Syu`, then restart the terminal and run `pacman -Su`. - * Run `pacman -S base-devel mingw-w64-x86_64-toolchain git bc` + * Run `pacman -S base-devel mingw-w64-x86_64-toolchain bc` * Use `C:\Users\` as the terminal $HOME by editing `C:\msys64\etc\nsswitch.conf` and changing the `db_home` value to `windows`. * You may need to work around an issue with envsubst.exe - you'll know there's a bug if git