Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add socket option for tmux window manager #28

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion backup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ RESTIC_HOSTNAME="" # Leave empty to use system hostname
LOCK_FILE="" # Optional lock file to acquire to ensure two backups don't run at once
LOCK_FILE_TIMEOUT="" # Optional lock file wait timeout (in seconds)
WINDOW_MANAGER="screen" # Choices: screen, tmux, RCON
TMUX_SOCKET="" # if -L is set will be defined as the tmux socket used

# Other Variables (do not modify)
DATE_FORMAT="%F_%H-%M-%S"
Expand Down Expand Up @@ -59,6 +60,7 @@ while getopts 'a:cd:e:f:hH:i:l:m:o:p:qr:s:t:u:vw:x' FLAG; do
echo "-H Set hostname for restic backup (restic only)"
echo "-i Input directory (path to world folder, use -i once for each world)"
echo "-l Compression level (default: 3)"
echo "-L tmux socket name"
echo "-m Maximum backups to keep, use -1 for unlimited (default: 128)"
echo "-o Output directory"
echo "-p Prefix that shows in Minecraft chat (default: Backup)"
Expand All @@ -74,6 +76,7 @@ while getopts 'a:cd:e:f:hH:i:l:m:o:p:qr:s:t:u:vw:x' FLAG; do
H) RESTIC_HOSTNAME=$OPTARG ;;
i) SERVER_WORLDS+=("$OPTARG") ;;
l) COMPRESSION_LEVEL=$OPTARG ;;
L) TMUX_SOCKET=$OPTARG ;;
m) MAX_BACKUPS=$OPTARG ;;
o) BACKUP_DIRECTORY=$OPTARG ;;
p) PREFIX=$OPTARG ;;
Expand Down Expand Up @@ -262,7 +265,13 @@ execute-command () {
case $WINDOW_MANAGER in
"screen") screen -S "$SCREEN_NAME" -p 0 -X stuff "$COMMAND$(printf \\r)"
;;
"tmux") tmux send-keys -t "$SCREEN_NAME" "$COMMAND" ENTER
"tmux")
if [[ $TMUX_SOCKET != "" ]]; then
tmux -L "$TMUX_SOCKET" send-keys -t "$SCREEN_NAME" "$COMMAND" ENTER
else
tmux send-keys -t "$SCREEN_NAME" "$COMMAND" ENTER
fi

;;
"RCON"|"rcon") rcon-command "$SCREEN_NAME" "$COMMAND"
;;
Expand Down