Add some scripts
This commit is contained in:
parent
cbc753a6bf
commit
8990eb866d
13
bin/arm_dir_files.bat
Normal file
13
bin/arm_dir_files.bat
Normal file
|
@ -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
|
46
bin/aws-list-deep-glacier-files
Normal file
46
bin/aws-list-deep-glacier-files
Normal file
|
@ -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 <bucket-name> <path-in-bucket> <output-file>"
|
||||||
|
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"
|
69
bin/aws-restore-deep-glacier-folder
Normal file
69
bin/aws-restore-deep-glacier-folder
Normal file
|
@ -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 <bucket-name> <path-in-bucket> <local-temp-dir>"
|
||||||
|
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
|
58
bin/backup-svn-repo
Normal file
58
bin/backup-svn-repo
Normal file
|
@ -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: <svn repo path> <output path>"
|
||||||
|
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
|
13
bin/disarm_dir_files.bat
Normal file
13
bin/disarm_dir_files.bat
Normal file
|
@ -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
|
62
bin/restore-svn-backup
Normal file
62
bin/restore-svn-backup
Normal file
|
@ -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: <backup file path> <svn repo path>"
|
||||||
|
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
|
|
@ -122,7 +122,7 @@ processor time and is generally useless.
|
||||||
tools/packages).
|
tools/packages).
|
||||||
* Open `C:\msys64\mingw64.exe`
|
* Open `C:\msys64\mingw64.exe`
|
||||||
* Run `pacman -Syu`, then restart the terminal and run `pacman -Su`.
|
* 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\<user>` as the terminal $HOME by editing `C:\msys64\etc\nsswitch.conf` and
|
* Use `C:\Users\<user>` as the terminal $HOME by editing `C:\msys64\etc\nsswitch.conf` and
|
||||||
changing the `db_home` value to `windows`.
|
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
|
* You may need to work around an issue with envsubst.exe - you'll know there's a bug if git
|
||||||
|
|
Loading…
Reference in New Issue
Block a user