1 #!/bin/bash
 2 
 3 ###################################################################
 4 # Generate some dummy data to test tildecraftBAK.sh
 5 #
 6 # Set paths and connection arguments here and in tildecraftBAK.sh
 7 # After running, check the data was created then run:
 8 # tildecraftBAK.sh -b hourly; tildecraftBAK.sh -c hourly
 9 # and view the results
10 ###################################################################
11 
12 # local paths
13 MC_PATH="$HOME/test"
14 WORLDS_DIR="$MC_PATH/worlds"
15 PLUGINS_DIR="$MC_PATH/plugins"
16 LOG_FILE="$MC_PATH/backup.log"
17 
18 # remote paths
19 BACKUP_PATH="/tmp/test"
20 
21 # timestamp format
22 NEW_FOLDER=$(date +"%Y/%B/%d/%H:%M")
23 TIMESTAMP=$(date +"%D %T")
24 
25 # remote connection arguments
26 # note: ssh uses lowercase -p for the port; sftp uses uppercase -P
27 SFTP_ARGS=(-P 32 -i /path/to/key user@127.0.0.1)
28 SSH_ARGS=(-p 32 -i /path/to/key user@127.0.0.1)
29 
30 
31 ####################
32 # TEST
33 ####################
34 
35 # debug messages
36 echo "target backup directory: $NEW_FOLDER"
37 echo "log timestamp: $TIMESTAMP"
38 
39 # dummy world
40 echo "Making a fake local world..."
41 mkdir -p "$WORLDS_DIR"/world
42 mkdir -p "$PLUGINS_DIR"/dummy_plugin
43 echo "this is a test" > "$WORLDS_DIR"/world/test.txt
44 
45 # dummy remote backups
46 echo "Making some fake hourly backups on the remote server..."
47 bakday=$(date --date="1 day ago" +%d) # 1 day ago so the hourly cleanup function can clean them
48 ssh "${SSH_ARGS[@]}" "mkdir -p $BACKUP_PATH/2020/January/$bakday/{00..23}:00"