F5 iApp Automated Backup
Problem this snippet solves:
This is now available on GitHub!
Please look on GitHub for the latest version, and submit any bugs or questions as an "Issue" on GitHub:
(Note: DevCentral admin update - Daniel's project appears abandoned so it's been forked and updated to the link below. @damnski on github added some SFTP code that has been merged in as well.)
https://github.com/f5devcentral/f5-automated-backup-iapp
Intro
Building on the significant work of Thomas Schockaert (and several other DevCentralites) I enhanced many aspects I needed for my own purposes, updated many things I noticed requested on the forums, and added additional documentation and clarification. As you may see in several of my comments on the original posts, I iterated through several 2.2.x versions and am now releasing v3.0.0. Below is the breakdown!
Also, I have done quite a bit of testing (mostly on v13.1.0.1 lately) and I doubt I've caught everything, especially with all of the changes. Please post any questions or issues in the comments.
Cheers!
Daniel Tavernier (tabernarious)
Related posts:
- Git Repository for f5-automated-backup-iapp (https://github.com/tabernarious/f5-automated-backup-iapp)
- https://community.f5.com/t5/technical-articles/f5-automated-backups-the-right-way/ta-p/288454
- https://community.f5.com/t5/crowdsrc/complete-f5-automated-backup-solution/ta-p/288701
- https://community.f5.com/t5/crowdsrc/complete-f5-automated-backup-solution-2/ta-p/274252
- https://community.f5.com/t5/technical-forum/automated-backup-solution/m-p/24551
- https://community.f5.com/t5/crowdsrc/tkb-p/CrowdSRC
v3.2.1 (20201210)
- Merged v3.1.11 and v3.2.0 for explicit SFTP support (separate from SCP).
- Tweaked the SCP and SFTP upload directory handling; detailed instructions are in the iApp.
- Tested on 13.1.3.4 and 14.1.3
v3.1.11 (20201210)
- Better handling of UCS passphrases, and notes about characters to avoid.
- I successfully tested this exact passphrase in the 13.1.3.4 CLI (surrounded with single quote) and GUI (as-is): `~!@#$%^*()aB1-_=+[{]}:./?
- I successfully tested this exact passphrase in 14.1.3 (square-braces and curly-braces would not work): `~!@#$%^*()aB1-_=+:./?
- Though there may be situations these could work, avoid these characters (separated by spaces): " ' & | ; < > \ [ ] { } ,
- Moved changelog and notes from the template to CHANGELOG.md and README.md.
- Replaced all tabs (\t) with four spaces.
v3.1.10 (20201209)
- Added SMB Version and SMB Security options to support v14+ and newer versions of Microsoft Windows and Windows Server.
- Tested SMB/CIFS on 13.1.3.4 and 14.1.3 against Windows Server 2019 using "2.0" and "ntlmsspi"
v3.1.0:
- Removed "app-service none" from iCall objects. The iCall objects are now created as part of the Application Service (iApp) and are properly cleaned up if the iApp is redeployed or deleted.
- Reasonably tested on 11.5.4 HF2 (SMB worked fine using "mount -t cifs") and altered requires-bigip-version-min to match.
- Fixing error regarding "script did not successfully complete: (can't read "::destination_parameters__protocol_enable": no such variable" by encompassing most of the "implementation" in a block that first checks $::backup_schedule__frequency_select for "Disable".
- Added default value to "filename format".
- Changed UCS default value for $backup_file_name_extension to ".ucs" and added $fname_noext.
- Removed old SFTP sections and references (now handled through SCP/SFTP).
- Adjusted logging: added "sleep 1" to ensure proper logging; added $backup_directory to log message.
- Adjusted some help messages.
New v3.0.0 features:
- Supports multiple instances! (Deploy multiple copies of the iApp to save backups to different places or perhaps to keep daily backups locally and send weekly backups to a network drive.)
- Fully ConfigSync compatible! (Encrypted values now in $script instead of local file.)
- Long passwords supported! (Using "-A" with openssl which reads/writes base64 encoded strings as a single line.)
- Added $script error checking for all remote backup types! (Using 'catch' to prevent tcl errors when $script aborts.)
- Backup files are cleaned up after any $script errors due to new error checking.
- Added logging! (Run logs sent to '/var/log/ltm' via logger command which is compatible with BIG-IP Remote Logging configuration (syslog). Run logs AND errors sent to '/var/tmp/scriptd.out'. Errors may include plain-text passwords which should not be in /var/log/ltm or syslog.)
- Added custom cipher option for SCP! (In case BIG-IP and the destination server are not cipher-compatible out of the box.)
- Added StrictHostKeyChecking=no option. (This is insecure and should only be used for testing--lots of warnings.)
- Combined SCP and SFTP because they are both using SCP to perform the remote copy. (Easier to maintain!)
Original v1.x.x and v2.x.x features kept (copied from an original post):
- It allows you to choose between both UCS or SCF as backup-types. (whilst providing ample warnings about SCF not being a very good restore-option due to the incompleteness in some cases)
- It allows you to provide a passphrase for the UCS archives (the standard GUI also does this, so the iApp should too)
- It allows you to not include the private keys (same thing: standard GUI does it, so the iApp does it too)
- It allows you to set a Backup Schedule for every X minutes/hours/days/weeks/months or a custom selection of days in the week
- It allows you to set the exact time, minute of the hour, day of the week or day of the month when the backup should be performed (depending on the usefulness with regards to the schedule type)
- It allows you to transfer the backup files to external devices using 4 different protocols, next to providing local storage on the device itself
- SCP (username/private key without password)
- SFTP (username/private key without password)
- FTP (username/password)
- SMB (now using TMOS v12.x.x compatible 'mount -t cifs', with username/password)
- Local Storage (/var/local/ucs or /var/local/scf)
- It stores all passwords and private keys in a secure fashion: encrypted by the master key of the unit (f5mku), rendering it safe to store the backups, including the credentials off-box
- It has a configurable automatic pruning function for the Local Storage option, so the disk doesn't fill up (i.e. keep last X backup files)
- It allows you to configure the filename using the date/time wildcards from the tcl [clock] command, as well as providing a variable to include the hostname
- It requires only the WebGUI to establish the configuration you desire
- It allows you to disable the processes for automated backup, without you having to remove the Application Service or losing any previously entered settings
- For the external shellscripts it automatically generates, the credentials are stored in encrypted form (using the master key)
- It allows you to no longer be required to make modifications on the linux command line to get your automated backups running after an RMA or restore operation
- It cleans up after itself, which means there are no extraneous shellscripts or status files lingering around after the scripts execute
How to use this snippet:
- Find and download the latest iApp template on GitHub (e.g "f5.automated_backup.v3.2.1.tmpl.tcl").
- Import the text file as an iApp Template in the BIG-IP GUI.
- Create an Application Service using the imported Template.
- Answer the questions (paying close attention to the help sections).
- Check /var/tmp/scriptd.out for general logs and errors.
Tested this on version:
16.0
- paulfishNimbostratus
A word of WARNING when using this iApp, always check the file it produces, whether on the box or copied to another location. I have had 2 installations where I have used it and the ucs archives it produced were not usable. The problem occurs when you install/configure the iApp and then upgrade the BigIP version. It's not enough just to run reconfigure, you need to delete the configured iApp and redeploy after the upgrade. I had the issue with 12.1.x > 13.1.1, 13.1.0.8 > 13.1.1. Strangely I don't think it occurred with 13.1.1 > 14.1.0.6, I was using the latest version of the iApp. Anyways, always check the archive, I got caught out, once it's set up and running it has been excellent, very reliable. When I do upgrades now, I run the iApp, recover the backup archive to the F5 from the remote location, load sys ucs, reboot and then go active. This way I have tested the complete recovery process immediately after upgrade and before going active.
- raj_bjs77Nimbostratus
can someone share the same iapp with sftp/scp username and password option instead of using private key
- Josh_StutzmanNimbostratus
This is a fantastic back up tool and is working great on our physical LTM hardware running 13.1.1.4 code and using an SMB share. However, the iApp is completely hung and I'm unable to access the reconfigure tab or run backups in our VE devices running the same code in VMware. Has anyone seen this behavior or have ideas on troubleshooting/debugging? The scriptd.out file contains only information on the last successful backup. The first several days the iApp worked without issue but now it is unresponsive. I've even removed and readded the template file with no change. However it's running fine on our physical i5600s. Any thoughts?
Guys everything works fine but it breaks with filezilla at the end with error 550 invalid filename, seems like an FZ issue with a missing "/" or something.
Did anyone face this?
(000010)4/9/2019 15:36:11 PM - (not logged in) (10.1.62.42)> 215 UNIX emulated by FileZilla (000010)4/9/2019 15:36:11 PM - (not logged in) (10.1.62.42)> USER labftp (000010)4/9/2019 15:36:11 PM - (not logged in) (10.1.62.42)> 331 Password required for labftp (000010)4/9/2019 15:36:11 PM - (not logged in) (10.1.62.42)> PASS ********** (000010)4/9/2019 15:36:11 PM - labftp (10.1.62.42)> 230 Logged on (000010)4/9/2019 15:36:11 PM - labftp (10.1.62.42)> TYPE I (000010)4/9/2019 15:36:11 PM - labftp (10.1.62.42)> 200 Type set to I (000010)4/9/2019 15:36:11 PM - labftp (10.1.62.42)> PASV (000010)4/9/2019 15:36:11 PM - labftp (10.1.62.42)> 227 Entering Passive Mode (10,1,62,201,219,75) (000010)4/9/2019 15:36:11 PM - labftp (10.1.62.42)> STOR /ftpsrv/20190409_bigip2.akmlab.local.ucs (000010)4/9/2019 15:36:11 PM - labftp (10.1.62.42)> 550 Filename invalid (000010)4/9/2019 15:36:11 PM - labftp (10.1.62.42)> QUIT (000010)4/9/2019 15:36:11 PM - labftp (10.1.62.42)> 221 Goodbye (000010)4/9/2019 15:36:11 PM - labftp (10.1.62.42)> disconnected. (000011)4/9/2019 15:36:27 PM - (not logged in) (10.1.62.41)> Connected on port 21, sending welcome message... (000011)4/9/2019 15:36:27 PM - (not logged in) (10.1.62.41)> 220-FileZilla Server 0.9.60 beta (000011)4/9/2019 15:36:27 PM - (not logged in) (10.1.62.41)> 220-written by Tim Kosse (tim.kosse@filezilla-project.org) (000011)4/9/2019 15:36:27 PM - (not logged in) (10.1.62.41)> 220 Please visit https://filezilla-project.org/ (000011)4/9/2019 15:36:27 PM - (not logged in) (10.1.62.41)> SYST (000011)4/9/2019 15:36:27 PM - (not logged in) (10.1.62.41)> 215 UNIX emulated by FileZilla (000011)4/9/2019 15:36:27 PM - (not logged in) (10.1.62.41)> USER labftp (000011)4/9/2019 15:36:27 PM - (not logged in) (10.1.62.41)> 331 Password required for labftp (000011)4/9/2019 15:36:27 PM - (not logged in) (10.1.62.41)> PASS ********** (000011)4/9/2019 15:36:27 PM - labftp (10.1.62.41)> 230 Logged on (000011)4/9/2019 15:36:27 PM - labftp (10.1.62.41)> TYPE I (000011)4/9/2019 15:36:27 PM - labftp (10.1.62.41)> 200 Type set to I (000011)4/9/2019 15:36:27 PM - labftp (10.1.62.41)> PASV (000011)4/9/2019 15:36:27 PM - labftp (10.1.62.41)> 227 Entering Passive Mode (10,1,62,201,244,80) (000011)4/9/2019 15:36:27 PM - labftp (10.1.62.41)> STOR /ftpsrv/20190409_bigip1.akmlab.local.ucs (000011)4/9/2019 15:36:27 PM - labftp (10.1.62.41)> 550 Filename invalid (000011)4/9/2019 15:36:27 PM - labftp (10.1.62.41)> QUIT (000011)4/9/2019 15:36:27 PM - labftp (10.1.62.41)> 221 Goodbye (000011)4/9/2019 15:36:27 PM - labftp (10.1.62.41)> disconnected.
- Daniel_TavernieCirrostratus
@aires: That "Amount of files" should only apply to pruning. Has it affected things in other ways?
@Jaques DL: I have not had time to look into the v14 changes that are producing the "Please enter password" error. I suspect it has something to do with under-the-hood changes that were made. I am hoping to look into this further in the coming weeks.
@Firewally: The "scripts" files are not needed for implementing this; they are simply for reference. I may rearrange things on GitHub to be more clear. Depending on what type of backups you're doing, there are some "pruning" options to remove old backups. The pruning options are count-based, not time-based, but since you have control over the frequency of the backups you could calculate a count to equal ~14 days worth of backups.
- FirewallyNimbostratus
Hi, th automated-backup iApp is great. Thanks.
What should I do with the shellscripts e.g. () Where I have to install ist or where I have this to store it?
Are there scripts available for removing backups remotly e.g older 14 days?
kind regards
Michael
- Jacques_DL_3369Nimbostratus
Hi All @ tabernarious
Any feedback or update regarding this error?
Please enter password with the systemd-tty-ask-password-agent tool!
- aries22Altocumulus
Hi! First off, thank you very much for sharing this. So cool and super helpful!
Can anyone tell me what the field "Amount of files to keep at any given time:" is for? I thought this was in relation to automatic pruning - will only prune files exceeding the value for this field, however it seems it is not for this purpose.
- Sebastian_Agui1Altostratus
Sick job dude, you saved me a lot of time, but i have a problem importing the template on some devices, i'm getting the following message: "Loading configuration... Loading schema version: 13.1.1.2 Unexpected Error: Can't find specified cli schema data for 13.1.1.2" on BIG-IP 13.1.1.4 Build 0.0.4 Point Release 4.
- DelbruggeNimbostratus
Getting this error on 11.6.0
Jan 29 23:14:47 bigip1 err scriptd[20085]: 014f0013:3: Script (/Common/) generated this Tcl error: (script did not successfully complete: (UCS saving process failed. while executing "tmsh::save /sys ucs $fname passphrase testpass$%0 " line:18))
EDIT: This was an issue on the VE that I was running this on with encryption. Nothing wrong with this script.