Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- # THIS SCRIPT WILL BACKUP AN OFFLINE LXD CONTAINER
- # CHANGE THE FPATH VARIABLE BELOW TO YOUR DESIRED OUTPUT FOLDER PATH
- # SET OUTPUT DIRECTORY
- FPATH='/share/ZFS22_DATA/Container'
- # CREATE TIME VARIABLE
- TIME="$(date "+%m.%d.%Y_%I.%M.%S.%p")"
- # DISPLAY THE AVAILABLE PACKAGES FOR EXPORT
- clear; lxc list
- # DISPLAY THE CURRENT WORKING DIRECTORY
- echo -e "\\nWorking directory: $pwd\\n"
- # PROMPT USER FOR INPUT
- read -p 'Enter the input container name: ' cName
- echo
- read -p 'Enter the output file name (date and extension will be appended): ' oName
- # DISPLAY THE USER'S CHOICES BEFORE EXECUTING
- clear; echo -e "Input: $cName\\nOutput: $FPATH/$oName-$TIME.tar.gz\\n"
- # PROMPT USER TO CONTINUE
- read -t 30 -p "IMPORTANT: You have 30 seconds to cancel... Press Enter to continue"
- # DISPLAY COMMAND LINE USED
- clear; echo -e "Executing: lxc export \"$cName\" \"$FPATH/$oName-$TIME.tar.gz\" --optimized-storage -v\\n"
- # COMPRESSED MODE
- lxc export "$cName" "$FPATH/$oName-$TIME.tar.gz" --optimized-storage -v
- # UN-COMPRESSED MODE... UNCOMMENT THIS IF DESIRED
- # MAKE SURE YOU COMMENT OUT THE ABOVE COMMAND IF YOU DECIDE TO USE THIS ONE.
- # lxc export "$cName" "$FPATH/$oName-$TIME.tar.gz" --optimized-storage --compression none -v
- # REMOVE GLOBAL TIME VARIABLE
- unset TIME
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement