diff options
Diffstat (limited to 'util/download-latest-save.bash')
| -rw-r--r-- | util/download-latest-save.bash | 18 |
1 files changed, 13 insertions, 5 deletions
diff --git a/util/download-latest-save.bash b/util/download-latest-save.bash index 2a84660..2ab5c62 100644 --- a/util/download-latest-save.bash +++ b/util/download-latest-save.bash @@ -1,18 +1,26 @@ #!/bin/bash # Check if remote name is provided -if [ $# -ne 1 ]; then - echo "Usage: $0 <remote_name>" +if [ $# -ne 1 -a $# -ne 2 ]; then + echo "Usage: $0 <remote_name> [optional_path_to_MyKey.pem]" exit 1 fi remote_name="$1" +key_path="" + +# Check if remote name is provided +if [ $# -eq 2 ]; then + key_path="-i $2" +fi # Generate a human-readable timestamp timestamp=$(date +"%Y-%m-%d_%H-%M-%S") + + # SSH into the remote instance to find the most recent save file -ssh_output=$(ssh "ec2-user@$remote_name" << EOF +ssh_output=$(ssh $key_path "ec2-user@$remote_name" << EOF # Record the current directory current_dir=\$(pwd) @@ -59,9 +67,9 @@ latest_file=$(basename "$latest_file_path") # Download the file from the remote instance to the current local directory with the new filename new_filename="${remote_name}_${timestamp}_${latest_file}" -scp "ec2-user@$remote_name:$latest_file_path" "./$new_filename" +scp $key_path "ec2-user@$remote_name:$latest_file_path" "./$new_filename" # Clean up the temporary file on the remote instance -ssh "ec2-user@$remote_name" "rm -f $latest_file_path" +ssh $key_path "ec2-user@$remote_name" "rm -f $latest_file_path" echo "Download complete. The latest save file has been saved as '$new_filename' in your current directory."
\ No newline at end of file |
