forked from tabernarious/f5-automated-backup-iapp
-
Notifications
You must be signed in to change notification settings - Fork 1
/
f5.automated_backup.v3.1.2.tmpl.tcl
689 lines (676 loc) · 62.3 KB
/
f5.automated_backup.v3.1.2.tmpl.tcl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
# iApp VERSIONS (From what I gathered perusing DevCentral)
# ~v2.0 - 20140312 - Initially posted releases (v11.4.0-11.6.x? compatibility). (Developed/posted by Thomas Schockaert)
# v2.1.1 - 20160916 - Retooled SMB upload from smbclient to "mount -t cifs" (v12.1+ compatibility). (Developed/posted by MAG)
# v2.2.1 - 20171214 - Allowed multiple instances of iApp by leveraging $tmsh::app_name to create unique object names. (Developed by Daniel Tavernier/tabernarious)
# v2.2.2 - 20171214 - Added "/" to "mount -t cifs" command and clarified/expanded help for SMB (CIFS) Destination Parameters. (Developed by Daniel Tavernier/tabernarious)
# v2.2.3 - 20171214 - Set many fields to "required" and set reasonable default values to prevent loading/configuration errors. Expanded help regarding private keys. (Developed by Daniel Tavernier/tabernarious)
# v2.2.4 - 20171214 - Added fix to force FTP to use binary upload. (Copied code posted by Roy van Dongen, posted by Daniel Tavernier/tabernarious)
# v2.2.4a - 20171215 - Added items to FUTURE list.
# v2.2.5 - 20171228 - Added notes about special characters in passwords. Added Deployment Information and ConfigSync sections. (Developed by Daniel Tavernier/tabernarious)
# v2.2.5a - 20180117 - Added items to FUTURE list.
# v2.2.5b4 - 20180118 - Moved encrypted values for SMB/CIFS to shell script which eliminates ConfigSync issues. Fixed long-password issue by using "-A" with openssl so that base64 encoded strings are written and read as a single line. (Developed by Daniel Tavernier/tabernarious)
# v2.2.5b4+ - 20180118 - Refining changes to SMB/CIFS and replicating to other remote copy types. (Developed by Daniel Tavernier/tabernarious)
# v3.0.0 - 20180124 - (Developed by Daniel Tavernier/tabernarious)
# - Eliminated ConfigSync issues and removed ConfigSync notes section. (Encrypted values now in $script instead of local file.)
# - Passwords now have no length limits. (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 $script error 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.
# - Added StrictHostKeyChecking=no option.
# - Combined SCP and SFTP because they are both using SCP to perform the remote copy.
# v3.1.0 - 20180201 - (Developed by Daniel Tavernier/tabernarious)
# - 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.
# v3.1.1 - 20180331 - Removed TCL double substitution warnings
# - Fixed duplication of UCS file extension when uploading to FTP
# v3.1.2 - 20180510 - Allowed Destination to be an IP or hostname, and added clarifying notes.
# - Added Source IP notes to help users understand and manipulate the source IP used by BIG-IP.
# - Added path notes for SFTP/SCP and FTP.
# - Fixed ssh-keygen example syntax and added note about optional ssh-copy-id command.
# - Clarified SMB/CIFS special character escaping for password--not all non-alphanumeric characters need to be escaped.
# KNOWN ISSUES
# - Passwords with special characters may cause tcl or bash errors; a backslash must be entered by the user in front of some special character for proper escaping.
# - F5 TMOS 11.4.1 - 11.5.3 untested and may work.
# - Automatic pruning is not used for network backups.
#REFERENCES
# Git Repository for f5-automated-backup-iapp ( https://github.com/tabernarious/f5-automated-backup-iapp )
# F5 iApp Automated Backup ( https://devcentral.f5.com/codeshare/f5-iapp-automated-backup-1114 )
# F5 Automated Backups - The Right Way ( https://devcentral.f5.com/articles/f5-automated-backups-the-right-way )
# PASTEBIN f5.automated_backup_v2.0 ( https://pastebin.com/YbDj3eMN )
# Complete F5 Automated Backup Solution ( https://devcentral.f5.com/codeshare/complete-f5-automated-backup-solution?lc=1 )
# Complete F5 Automated Backup Solution #2 ( https://devcentral.f5.com/codeshare/complete-f5-automated-backup-solution-2-957 )
# Automated Backup Solution ( https://devcentral.f5.com/questions/automated-backup-solution )
# Generate Config Backup ( https://devcentral.f5.com/codeshare?sid=285 )
# PASTEBIN f5.automated_backup_v3.0.0 ( https://pastebin.com/TENAivwW )
cli admin-partitions {
update-partition Common
}
sys application template /Common/f5.automated_backup.v3.1.2 {
actions {
definition {
html-help {
}
implementation {
package require iapp 1.0.0
iapp::template start
tmsh::cd ..
## Backup type handler
set backup_type $::backup_type__backup_type_select
set create_backup_command_append_pass ""
set create_backup_command_append_keys ""
if { $backup_type eq "UCS (User Configuration Set)" } {
set create_backup_command "tmsh::save /sys ucs"
set backup_directory /var/local/ucs
# Backup passphrase usage
if { $::backup_type__backup_passphrase_select eq "Yes" } {
set backup_passphrase $::backup_type__backup_passphrase
set create_backup_command_append_pass "passphrase $backup_passphrase"
}
# Backup private key inclusion
if { $::backup_type__backup_includeprivatekeys eq "No" } {
set create_backup_command_append_keys "no-private-key"
}
set backup_file_name ""
set backup_file_name_extension ".ucs"
set backup_file_script_extension ".ucs"
}
elseif { $backup_type eq "SCF (Single Configuration File)" } {
set create_backup_command "tmsh::save /sys config file"
set backup_directory /var/local/scf
set backup_file_name_extension ".scf"
set backup_file_script_extension ".scf"
}
set freq $::backup_schedule__frequency_select
if { $freq != "Disable" } {
# Ensure a default $filename_format is set
if { $::destination_parameters__filename_format eq "" } {
set filename_format {${host}_%Y%m%d_%H%M%S}
}
else {
set filename_format [lindex [split $::destination_parameters__filename_format " "] 0]
}
if { $::destination_parameters__protocol_enable eq "Remotely via SCP/SFTP" } {
# Get the F5 Master key
set f5masterkey [exec f5mku -K]
# Store the target server information securely, encrypted with the unit key
set encryptedusername [exec echo "$::destination_parameters__scp_remote_username" | openssl aes-256-ecb -salt -a -A -k ${f5masterkey}]
set encryptedserver [exec echo "$::destination_parameters__scp_remote_server" | openssl aes-256-ecb -salt -a -A -k ${f5masterkey}]
set encrypteddirectory [exec echo "$::destination_parameters__scp_remote_directory" | openssl aes-256-ecb -salt -a -A -k ${f5masterkey}]
# Clean the private key data before cleanup
set cleaned_privatekey [exec echo "$::destination_parameters__scp_sshprivatekey" | sed -e "s/BEGIN RSA PRIVATE KEY/BEGIN;RSA;PRIVATE;KEY/g" -e "s/END RSA PRIVATE KEY/END;RSA;PRIVATE;KEY/g" -e "s/ /\\\n/g" -e "s/;/ /g"]
# Encrypt the private key data before dumping to a file
set encrypted_privatekey [exec echo "$cleaned_privatekey" | openssl aes-256-ecb -salt -a -A -k ${f5masterkey}]
# Set optional cipher for SCP (e.g. [email protected])
if { "$::destination_parameters__scp_cipher" equals "" } {
set scp_cipher ""
} else {
set scp_cipher "-c $::destination_parameters__scp_cipher"
}
# Set optional "StrictHostKeyChecking=no"
if { "$::destination_parameters__scp_stricthostkeychecking" equals "Yes" } {
set scp_stricthostkeychecking "-o StrictHostKeyChecking=yes"
} else {
set scp_stricthostkeychecking "-o StrictHostKeyChecking=no"
}
# Create the iCall action
set script {
exec echo "f5.automated_backup iApp TMSHAPPNAME: STARTED" >> /var/tmp/scriptd.out
exec logger -p local0.info "f5.automated_backup iApp TMSHAPPNAME: STARTED"
# Get the hostname of the device we're running on
set host [tmsh::get_field_value [lindex [tmsh::get_config sys global-settings] 0] hostname]
# Get the current date and time in a specific format
set cdate [clock format [clock seconds] -format "FORMAT"]
# Form the filename for the backup
set fname_noext "${cdate}"
set fname "${cdate}BACKUPFILENAMEXTENSION"
# Run the 'create backup' command
exec echo "f5.automated_backup iApp TMSHAPPNAME: $fname GENERATING" >> /var/tmp/scriptd.out
exec logger -p local0.info "f5.automated_backup iApp TMSHAPPNAME: $fname GENERATING"
# Delay 1 second to allow proper logging to /var/tmp/scriptd.out
exec sleep 1
BACKUPCOMMAND $fname BACKUPAPPEND_PASS BACKUPAPPEND_KEYS
exec echo "f5.automated_backup iApp TMSHAPPNAME: $fname SAVED LOCALLY (BACKUPDIRECTORY)" >> /var/tmp/scriptd.out
exec logger -p local0.info "f5.automated_backup iApp TMSHAPPNAME: $fname SAVED LOCALLY (BACKUPDIRECTORY)"
# Set the script filename
set scriptfile "/var/tmp/f5.automated_backup__TMSHAPPNAME_scp.sh"
# Clean, recreate, and run a custom bash script that will perform the SCP upload
exec rm -f $scriptfile
exec echo "yes"
exec echo -e "scp_function()\n{\n\tf5masterkey=\$(f5mku -K)\n\tusername=\$(echo \"ENCRYPTEDUSERNAME\" | openssl aes-256-ecb -salt -a -A -d -k \${f5masterkey})\n\tserver=\$(echo \"ENCRYPTEDSERVER\" | openssl aes-256-ecb -salt -a -A -d -k \${f5masterkey})\n\tdirectory=\$(echo \"ENCRYPTEDDIRECTORY\" | openssl aes-256-ecb -salt -a -A -d -k \${f5masterkey})\n\techo \"ENCRYPTEDPRIVATEKEY\" | openssl aes-256-ecb -salt -a -A -d -k \${f5masterkey} > /var/tmp/TMSHAPPNAME_scp.key\n\n\tchmod 600 /var/tmp/TMSHAPPNAME_scp.key\n\tscp -i /var/tmp/TMSHAPPNAME_scp.key SCPCIPHER SCPSTRICTHOSTKEYCHECKING BACKUPDIRECTORY/${fname_noext}BACKUPFILESCRIPTEXTENSION \${username}@\${server}:\${directory} 2>> /var/tmp/scriptd.out\n\tscp_result=\$?\n\trm -f /var/tmp/TMSHAPPNAME_scp.key\n\treturn \$scp_result\n}\n\nscp_function" > $scriptfile
exec chmod +x $scriptfile
exec echo "f5.automated_backup iApp TMSHAPPNAME: $fname REMOTE COPY (SCP) STARTING" >> /var/tmp/scriptd.out
exec logger -p local0.info "f5.automated_backup iApp TMSHAPPNAME: $fname REMOTE COPY (SCP) STARTING"
if { [catch {exec $scriptfile}] } {
exec echo "f5.automated_backup iApp TMSHAPPNAME: $fname REMOTE COPY (SCP) FAILED (check for errors above)" >> /var/tmp/scriptd.out
exec logger -p local0.crit "f5.automated_backup iApp TMSHAPPNAME: $fname REMOTE COPY (SCP) FAILED (see /var/tmp/scriptd.out for errors)"
} else {
exec echo "f5.automated_backup iApp TMSHAPPNAME: $fname REMOTE COPY (SCP) SUCCEEDED" >> /var/tmp/scriptd.out
exec logger -p local0.notice "f5.automated_backup iApp TMSHAPPNAME: $fname REMOTE COPY (SCP) SUCCEEDED"
}
# Clean up local files
exec rm -f $scriptfile
exec rm -f /var/tmp/TMSHAPPNAME_scp.key
exec rm -f BACKUPDIRECTORY/${fname_noext}BACKUPFILESCRIPTEXTENSION
exec echo "f5.automated_backup iApp TMSHAPPNAME: FINISHED" >> /var/tmp/scriptd.out
exec logger -p local0.info "f5.automated_backup iApp TMSHAPPNAME: FINISHED"
}
# Swap many variables into $script; due to the curly braces used to initially set $script, any referenced variables will *not* be expanded simply by deploying the iApp.
set script [string map [list FORMAT $filename_format BACKUPFILENAMEXTENSION $backup_file_name_extension BACKUPFILESCRIPTEXTENSION $backup_file_script_extension BACKUPDIRECTORY $backup_directory BACKUPCOMMAND $create_backup_command BACKUPAPPEND_PASS $create_backup_command_append_pass BACKUPAPPEND_KEYS $create_backup_command_append_keys TMSHAPPNAME $tmsh::app_name ENCRYPTEDUSERNAME $encryptedusername ENCRYPTEDSERVER $encryptedserver ENCRYPTEDDIRECTORY $encrypteddirectory ENCRYPTEDPRIVATEKEY $encrypted_privatekey SCPCIPHER $scp_cipher SCPSTRICTHOSTKEYCHECKING $scp_stricthostkeychecking] $script]
}
elseif { $::destination_parameters__protocol_enable eq "Remotely via FTP" } {
# Get the F5 Master key
set f5masterkey [exec f5mku -K]
# Store the target server information securely, encrypted with the unit key
set encryptedusername [exec echo "$::destination_parameters__ftp_remote_username" | openssl aes-256-ecb -salt -a -A -k ${f5masterkey}]
set encryptedpassword [exec echo "$::destination_parameters__ftp_remote_password" | openssl aes-256-ecb -salt -a -A -k ${f5masterkey}]
set encryptedserver [exec echo "$::destination_parameters__ftp_remote_server" | openssl aes-256-ecb -salt -a -A -k ${f5masterkey}]
set encrypteddirectory [exec echo "$::destination_parameters__ftp_remote_directory" | openssl aes-256-ecb -salt -a -A -k ${f5masterkey}]
# Create the iCall action
set script {
exec echo "f5.automated_backup iApp TMSHAPPNAME: STARTED" >> /var/tmp/scriptd.out
exec logger -p local0.info "f5.automated_backup iApp TMSHAPPNAME: STARTED"
# Get the hostname of the device we're running on
set host [tmsh::get_field_value [lindex [tmsh::get_config sys global-settings] 0] hostname]
# Get the current date and time in a specific format
set cdate [clock format [clock seconds] -format "FORMAT"]
# Form the filename for the backup
set fname_noext "${cdate}"
set fname "${cdate}BACKUPFILENAMEXTENSION"
# Run the 'create backup' command
exec echo "f5.automated_backup iApp TMSHAPPNAME: $fname GENERATING" >> /var/tmp/scriptd.out
exec logger -p local0.info "f5.automated_backup iApp TMSHAPPNAME: $fname GENERATING"
# Delay 1 second to allow proper logging to /var/tmp/scriptd.out
exec sleep 1
BACKUPCOMMAND $fname BACKUPAPPEND_PASS BACKUPAPPEND_KEYS
exec echo "f5.automated_backup iApp TMSHAPPNAME: $fname SAVED LOCALLY (BACKUPDIRECTORY)" >> /var/tmp/scriptd.out
exec logger -p local0.info "f5.automated_backup iApp TMSHAPPNAME: $fname SAVED LOCALLY (BACKUPDIRECTORY)"
# Set the config file
set configfile "/config/f5.automated_backup__TMSHAPPNAME_ftp.conf"
# Set the script filename
set scriptfile "/var/tmp/f5.automated_backup__TMSHAPPNAME_ftp.sh"
# Clean, recreate, run and reclean a custom bash script that will perform the FTP upload
exec rm -f $scriptfile
# Updated command v2.2.4 to force binary transfer.
exec echo -e "ftp_function()\n{\n\tf5masterkey=\$(f5mku -K)\n\tusername=\$(echo \"ENCRYPTEDUSERNAME\" | openssl aes-256-ecb -salt -a -A -d -k \${f5masterkey})\n\tpassword=\$(echo \"ENCRYPTEDPASSWORD\" | openssl aes-256-ecb -salt -a -A -d -k \${f5masterkey})\n\tserver=\$(echo \"ENCRYPTEDSERVER\" | openssl aes-256-ecb -salt -a -A -d -k \${f5masterkey})\n\tdirectory=\$(echo \"ENCRYPTEDDIRECTORY\" | openssl aes-256-ecb -salt -a -A -d -k \${f5masterkey})\n\n\tftp_return=\$(ftp -n \${server} << END_FTP\nquote USER \${username}\nquote PASS \${password}\nbinary\nput BACKUPDIRECTORY/${fname_noext}BACKUPFILESCRIPTEXTENSION \${directory}/${fname_noext}BACKUPFILESCRIPTEXTENSION\nquit\nEND_FTP\n)\n\tif \[ \"\$ftp_return\" == \"\" \]\n\tthen\n\t\treturn 0\n\telse\n\t\techo \"\$ftp_return\" >> /var/tmp/scriptd.out\n\t\treturn 1\n\tfi\n}\n\nftp_function" > $scriptfile
exec chmod +x $scriptfile
exec echo "f5.automated_backup iApp TMSHAPPNAME: $fname REMOTE COPY (FTP) STARTING" >> /var/tmp/scriptd.out
exec logger -p local0.info "f5.automated_backup iApp TMSHAPPNAME: $fname REMOTE COPY (FTP) STARTING"
if { [catch {exec $scriptfile}] } {
exec echo "f5.automated_backup iApp TMSHAPPNAME: $fname REMOTE COPY (FTP) FAILED (check for errors above)" >> /var/tmp/scriptd.out
exec logger -p local0.crit "f5.automated_backup iApp TMSHAPPNAME: $fname REMOTE COPY (FTP) FAILED (see /var/tmp/scriptd.out for errors)"
} else {
exec echo "f5.automated_backup iApp TMSHAPPNAME: $fname REMOTE COPY (FTP) SUCCEEDED" >> /var/tmp/scriptd.out
exec logger -p local0.notice "f5.automated_backup iApp TMSHAPPNAME: $fname REMOTE COPY (FTP) SUCCEEDED"
}
# Clean up local files
exec rm -f $scriptfile
exec rm -f BACKUPDIRECTORY/${fname_noext}BACKUPFILESCRIPTEXTENSION
exec echo "f5.automated_backup iApp TMSHAPPNAME: FINISHED" >> /var/tmp/scriptd.out
exec logger -p local0.info "f5.automated_backup iApp TMSHAPPNAME: FINISHED"
}
# Swap many variables into $script; due to the curly braces used to initially set $script, any referenced variables will *not* be expanded simply by deploying the iApp.
set script [string map [list FORMAT $filename_format BACKUPFILENAMEXTENSION $backup_file_name_extension BACKUPFILESCRIPTEXTENSION $backup_file_script_extension BACKUPDIRECTORY $backup_directory BACKUPCOMMAND $create_backup_command BACKUPAPPEND_PASS $create_backup_command_append_pass BACKUPAPPEND_KEYS $create_backup_command_append_keys TMSHAPPNAME $tmsh::app_name ENCRYPTEDUSERNAME $encryptedusername ENCRYPTEDPASSWORD $encryptedpassword ENCRYPTEDSERVER $encryptedserver ENCRYPTEDDIRECTORY $encrypteddirectory] $script]
}
elseif { $::destination_parameters__protocol_enable eq "Remotely via SMB/CIFS" } {
# Get the F5 Master key
set f5masterkey [exec f5mku -K]
# Store the target server information securely, encrypted with the unit key
set encryptedusername [exec echo "$::destination_parameters__smb_remote_username" | openssl aes-256-ecb -salt -a -A -k ${f5masterkey}]
set encryptedpassword [exec echo "$::destination_parameters__smb_remote_password" | openssl aes-256-ecb -salt -a -A -k ${f5masterkey}]
set encryptedmsdomain [exec echo "$::destination_parameters__smb_remote_domain" | openssl aes-256-ecb -salt -a -A -k ${f5masterkey}]
set encryptedserver [exec echo "$::destination_parameters__smb_remote_server" | openssl aes-256-ecb -salt -a -A -k ${f5masterkey}]
set encryptedmsshare [exec echo "$::destination_parameters__smb_remote_path" | openssl aes-256-ecb -salt -a -A -k ${f5masterkey}]
set encryptedmssubdir [exec echo "$::destination_parameters__smb_remote_directory" | openssl aes-256-ecb -salt -a -A -k ${f5masterkey}]
set encryptedmountp [exec echo "$::destination_parameters__smb_local_mountdir" | openssl aes-256-ecb -salt -a -A -k ${f5masterkey}]
# Create the iCall action
set script {
exec echo "f5.automated_backup iApp TMSHAPPNAME: STARTED" >> /var/tmp/scriptd.out
exec logger -p local0.info "f5.automated_backup iApp TMSHAPPNAME: STARTED"
# Get the hostname of the device we're running on
set host [tmsh::get_field_value [lindex [tmsh::get_config sys global-settings] 0] hostname]
# Get the current date and time in a specific format
set cdate [clock format [clock seconds] -format "FORMAT"]
# Form the filename for the backup
set fname_noext "${cdate}"
set fname "${cdate}BACKUPFILENAMEXTENSION"
# Run the 'create backup' command
exec echo "f5.automated_backup iApp TMSHAPPNAME: $fname GENERATING" >> /var/tmp/scriptd.out
exec logger -p local0.info "f5.automated_backup iApp TMSHAPPNAME: $fname GENERATING"
# Delay 1 second to allow proper logging to /var/tmp/scriptd.out
exec sleep 1
BACKUPCOMMAND $fname BACKUPAPPEND_PASS BACKUPAPPEND_KEYS
exec echo "f5.automated_backup iApp TMSHAPPNAME: $fname SAVED LOCALLY (BACKUPDIRECTORY)" >> /var/tmp/scriptd.out
exec logger -p local0.info "f5.automated_backup iApp TMSHAPPNAME: $fname SAVED LOCALLY (BACKUPDIRECTORY)"
# Set the script filename
set scriptfile "/var/tmp/f5.automated_backup__TMSHAPPNAME_smb.sh"
# Clean, recreate, run and reclean a custom bash script that will perform the SMB upload
exec rm -f $scriptfile
exec echo -e "\#\!/bin/sh\nf5masterkey=\$(f5mku -K)\nusername=\$(echo \"ENCRYPTEDUSERNAME\" | openssl aes-256-ecb -salt -a -A -d -k \${f5masterkey})\npassword=\$(echo \"ENCRYPTEDPASSWORD\" | openssl aes-256-ecb -salt -a -A -d -k \${f5masterkey})\nmsdomain=\$(echo \"ENCRYPTEDMSDOMAIN\" | openssl aes-256-ecb -salt -a -A -d -k \${f5masterkey})\nserver=\$(echo \"ENCRYPTEDSERVER\" | openssl aes-256-ecb -salt -a -A -d -k \${f5masterkey})\nmsshare=\$(echo \"ENCRYPTEDMSSHARE\" | openssl aes-256-ecb -salt -a -A -d -k \${f5masterkey})\nmssubdir=\$(echo \"ENCRYPTEDMSSUBDIR\" | openssl aes-256-ecb -salt -a -A -d -k \${f5masterkey})\nmountp=\$(echo \"ENCRYPTEDMOUNTP\" | openssl aes-256-ecb -salt -a -A -d -k \${f5masterkey})\ncd /var/local/ucs\nif \[ \! -d \${mountp} \]\nthen\n\tmkdir -p \${mountp}\n\tif \[ \$? -ne 0 \]\n\tthen\n\t\trm -f ${fname_noext}BACKUPFILESCRIPTEXTENSION\n\t\texit 1\n\tfi\nfi\nmount -t cifs //\${server}/\${msshare} \${mountp} -o user=\${username}%\${password},domain=\${msdomain} 2>> /var/tmp/scriptd.out\nif \[ \$? -ne 0 \]\n\tthen\n\trm -f ${fname_noext}BACKUPFILESCRIPTEXTENSION\n\texit 1\nfi\nfONSMB=\$(ls -t \${mountp}\${mssubdir}/\*.ucs 2>/dev/null| head -n 1 2>/dev/null)\nif \[ \"X\"\${fONSMB} \!= \"X\" \]\n\tthen\n\tsum1=\$(md5sum ${fname_noext}BACKUPFILESCRIPTEXTENSION | awk '{print \$1}')\n\tsum2=\$(md5sum \${fONSMB} | awk \'{print \$1}\')\n\tif \[ \${sum1} == \${sum2} \]\n\tthen\n\t\techo \"ERROR: File ${fname_noext}BACKUPFILESCRIPTEXTENSION already exists in //\${server}/\${msshare}/\${mssubdir}\" >> /var/tmp/scriptd.out\n\t\tumount \${mountp}\n\t\trm -f ${fname_noext}BACKUPFILESCRIPTEXTENSION\n\t\texit 1\n\tfi\nfi\ncp ${fname_noext}BACKUPFILESCRIPTEXTENSION \${mountp}\${mssubdir}\nrm -f ${fname_noext}BACKUPFILESCRIPTEXTENSION\numount \${mountp}\n\nexit 0\n\n" > $scriptfile
exec chmod +x $scriptfile
exec echo "f5.automated_backup iApp TMSHAPPNAME: $fname STARTING REMOTE COPY (SMB/CIFS)" >> /var/tmp/scriptd.out
exec logger -p local0.info "f5.automated_backup iApp TMSHAPPNAME: $fname REMOTE COPY (SMB/CIFS) STARTING"
if { [catch {exec $scriptfile}] } {
exec echo "f5.automated_backup iApp TMSHAPPNAME: $fname REMOTE COPY (SMB/CIFS) FAILED (check for errors above)" >> /var/tmp/scriptd.out
exec logger -p local0.crit "f5.automated_backup iApp TMSHAPPNAME: $fname REMOTE COPY (SMB/CIFS) FAILED (see /var/tmp/scriptd.out for errors)"
} else {
exec echo "f5.automated_backup iApp TMSHAPPNAME: $fname REMOTE COPY (SMB/CIFS) SUCCEEDED" >> /var/tmp/scriptd.out
exec logger -p local0.notice "f5.automated_backup iApp TMSHAPPNAME: $fname REMOTE COPY (SMB/CIFS) SUCCEEDED"
}
# Clean up local files
exec rm -f $scriptfile
exec rm -f BACKUPDIRECTORY/${fname_noext}BACKUPFILESCRIPTEXTENSION
exec echo "f5.automated_backup iApp TMSHAPPNAME: FINISHED" >> /var/tmp/scriptd.out
exec logger -p local0.info "f5.automated_backup iApp TMSHAPPNAME: FINISHED"
}
# Swap many variables into $script; due to the curly braces used to initially set $script, any referenced variables will *not* be expanded simply by deploying the iApp.
set script [string map [list FORMAT $filename_format BACKUPFILENAMEXTENSION $backup_file_name_extension BACKUPFILESCRIPTEXTENSION $backup_file_script_extension BACKUPDIRECTORY $backup_directory BACKUPCOMMAND $create_backup_command BACKUPAPPEND_PASS $create_backup_command_append_pass BACKUPAPPEND_KEYS $create_backup_command_append_keys TMSHAPPNAME $tmsh::app_name ENCRYPTEDUSERNAME $encryptedusername ENCRYPTEDPASSWORD $encryptedpassword ENCRYPTEDMSDOMAIN $encryptedmsdomain ENCRYPTEDSERVER $encryptedserver ENCRYPTEDMSSHARE $encryptedmsshare ENCRYPTEDMSSUBDIR $encryptedmssubdir ENCRYPTEDMOUNTP $encryptedmountp] $script]
}
else {
set script {
exec echo "f5.automated_backup iApp TMSHAPPNAME: STARTED" >> /var/tmp/scriptd.out
exec logger -p local0.info "f5.automated_backup iApp TMSHAPPNAME: STARTED"
# Get the hostname of the device we're running on
set host [tmsh::get_field_value [lindex [tmsh::get_config sys global-settings] 0] hostname]
# Get the current date and time in a specific format
set cdate [clock format [clock seconds] -format "FORMAT"]
# Form the filename for the backup
set fname "${cdate}BACKUPFILENAMEXTENSION"
# Run the 'create backup' command
exec echo "f5.automated_backup iApp TMSHAPPNAME: $fname GENERATING" >> /var/tmp/scriptd.out
exec logger -p local0.info "f5.automated_backup iApp TMSHAPPNAME: $fname GENERATING"
# Delay 1 second to allow proper logging to /var/tmp/scriptd.out
exec sleep 1
BACKUPCOMMAND $fname BACKUPAPPEND_PASS BACKUPAPPEND_KEYS
exec echo "f5.automated_backup iApp TMSHAPPNAME: $fname SAVED LOCALLY (BACKUPDIRECTORY)" >> /var/tmp/scriptd.out
exec logger -p local0.info "f5.automated_backup iApp TMSHAPPNAME: $fname SAVED LOCALLY (BACKUPDIRECTORY)"
exec echo "f5.automated_backup iApp TMSHAPPNAME: FINISHED" >> /var/tmp/scriptd.out
exec logger -p local0.info "f5.automated_backup iApp TMSHAPPNAME: FINISHED"
}
# Swap many variables into $script; due to the curly braces used to initially set $script, any referenced variables will *not* be expanded simply by deploying the iApp.
set script [string map [list FORMAT $filename_format BACKUPFILENAMEXTENSION $backup_file_name_extension BACKUPFILESCRIPTEXTENSION $backup_file_script_extension BACKUPDIRECTORY $backup_directory BACKUPCOMMAND $create_backup_command BACKUPAPPEND_PASS $create_backup_command_append_pass BACKUPAPPEND_KEYS $create_backup_command_append_keys TMSHAPPNAME $tmsh::app_name] $script]
}
iapp::conf create sys icall script f5.automated_backup__${tmsh::app_name} definition \{ $script \}
## Get time info for setting first-occurrence on daily handler from iApp input
#Create the handlers
if { $freq eq "Every X Minutes" } {
set everyxminutes $::backup_schedule__everyxminutes_value
set interval [expr {$everyxminutes*60}]
set cdate [clock format [clock seconds] -format "%Y-%m-%d:%H:%M"]
iapp::conf create sys icall handler periodic f5.automated_backup__${tmsh::app_name}-handler \{ \
interval $interval \
first-occurrence $cdate:00 \
script f5.automated_backup__${tmsh::app_name} \}
}
elseif { $freq eq "Every X Hours" } {
set everyxhours $::backup_schedule__everyxhours_value
set interval [expr {$everyxhours*3600}]
set minutes $::backup_schedule__everyxhours_min_select
set cdate [clock format [clock seconds] -format "%Y-%m-%d:%H"]
iapp::conf create sys icall handler periodic f5.automated_backup__${tmsh::app_name}-handler \{ \
interval $interval \
first-occurrence $cdate:$minutes:00 \
script f5.automated_backup__${tmsh::app_name} \}
}
elseif { $freq eq "Every X Days" } {
set everyxdays $::backup_schedule__everyxdays_value
set interval [expr {$everyxdays*86400}]
set hours [lindex [split $::backup_schedule__everyxdays_time ":"] 0]
set minutes [lindex [split $::backup_schedule__everyxdays_time ":"] 1]
set cdate [clock format [clock seconds] -format "%Y-%m-%d"]
iapp::conf create sys icall handler periodic f5.automated_backup__${tmsh::app_name}-handler \{ \
interval $interval \
first-occurrence $cdate:$hours:$minutes:00 \
script f5.automated_backup__${tmsh::app_name} \}
}
elseif { $freq eq "Every X Weeks" } {
set everyxweeks $::backup_schedule__everyxweeks_value
set interval [expr {$everyxweeks*604800}]
set hours [lindex [split $::backup_schedule__everyxweeks_time ":"] 0]
set minutes [lindex [split $::backup_schedule__everyxweeks_time ":"] 1]
## Get day of week info for setting first-occurrence on weekly handler from iApp input
array set dowmap {
Sunday 0
Monday 1
Tuesday 2
Wednesday 3
Thursday 4
Friday 5
Saturday 6
}
set sday_name $::backup_schedule__everyxweeks_dow_select
set sday_num $dowmap($sday_name)
set cday_name [clock format [clock seconds] -format "%A"]
set cday_num $dowmap($cday_name)
set date_offset [expr {86400*($sday_num - $cday_num)}]
set date_final [clock format [expr {[clock seconds] + $date_offset}] -format "%Y-%m-%d"]
iapp::conf create sys icall handler periodic f5.automated_backup__${tmsh::app_name}-handler \{ \
interval $interval \
first-occurrence $date_final:$hours:$minutes:00 \
script f5.automated_backup__${tmsh::app_name} \}
}
elseif { $freq eq "Every X Months" } {
set everyxmonths $::backup_schedule__everyxmonths_value
set interval [expr {60*60*24*365}]
set dom $::backup_schedule__everyxmonths_dom_select
set hours [lindex [split $::backup_schedule__everyxmonths_time ":"] 0]
set minutes [lindex [split $::backup_schedule__everyxmonths_time ":"] 1]
for { set month 1 } { $month < 13 } { set month [expr {$month+$everyxmonths}] } {
set cdate [clock format [clock seconds] -format "%Y-$month-$dom"]
iapp::conf create sys icall handler periodic f5.automated_backup__${tmsh::app_name}-month_${month}-handler \{ \
interval $interval \
first-occurrence $cdate:$hours:$minutes:00 \
script f5.automated_backup__${tmsh::app_name} \}
}
}
elseif { $freq eq "Custom" } {
set hours [lindex [split $::backup_schedule__custom_time ":"] 0]
set minutes [lindex [split $::backup_schedule__custom_time ":"] 1]
## Get day of week info for setting first-occurrence on weekly handler from iApp input
array set dowmap {
Sunday 0
Monday 1
Tuesday 2
Wednesday 3
Thursday 4
Friday 5
Saturday 6
}
foreach sday_name $::backup_schedule__custom_dow_select {
set sday_num $dowmap($sday_name)
set cday_name [clock format [clock seconds] -format "%A"]
set cday_num $dowmap($cday_name)
set date_offset [expr {86400*($sday_num - $cday_num)}]
set date_final [clock format [expr {[clock seconds] + $date_offset}] -format "%Y-%m-%d"]
iapp::conf create sys icall handler periodic f5.automated_backup__${tmsh::app_name}-handler-$sday_name \{ \
interval 604800 \
first-occurrence $date_final:$hours:$minutes:00 \
script f5.automated_backup__${tmsh::app_name} \}
}
}
else {
}
## Automatic Pruning handler
if { $::destination_parameters__protocol_enable eq "On this F5" } {
set autoprune $::destination_parameters__pruning_enable
if { $autoprune eq "Yes" } {
set prune_conserve $::destination_parameters__keep_amount
set today [clock format [clock seconds] -format "%Y-%m-%d"]
set script {
# Get the hostname of the device we're running on
set host [tmsh::get_field_value [lindex [tmsh::get_config sys global-settings] 0] hostname]
# Set the script filename
set scriptfile "/var/tmp/autopruning.sh"
# Clean, recreate, run and reclean a custom bash script that will perform the pruning
exec rm -f $scriptfile
exec echo -e "files_tokeep=\$(ls -t /var/local/ucs/*.ucs | head -n CONSERVE\)\nfor current_ucs_file in `ls /var/local/ucs/*.ucs` ; do\n\tcurrent_ucs_file_basename=`basename \$current_ucs_file`\n\tcheck_file=\$(echo \$files_tokeep | grep -w \$current_ucs_file_basename)\n\tif \[ \"\$check_file\" == \"\" \] ; then\n\t\trm -f \$current_ucs_file\n\tfi\ndone" > $scriptfile
exec chmod +x $scriptfile
exec $scriptfile
exec rm -f $scriptfile
}
set script [string map [list CONSERVE $prune_conserve] $script]
iapp::conf create sys icall script f5.automated_backup__${tmsh::app_name}_pruning definition \{ $script \}
set cdate [clock format [clock seconds] -format "%Y-%m-%d:%H:%M"]
# Interval can be increased as needed if pruning every minute is problematic
iapp::conf create sys icall handler periodic f5.automated_backup__${tmsh::app_name}_pruning-handler \{ \
interval 60 \
first-occurrence $cdate:00 \
script f5.automated_backup__${tmsh::app_name}_pruning \}
}
}
}
iapp::template end
}
macro {
}
presentation {
section deployment_info {
message deployment_info_first_time "Deploying the iApp may not trigger an immediate backup."
message deployment_info_updates "For testing, to force the iApp to run an immediate backup it is easiest to set the Backup Schedule to 'Every X Minutes' and simply change value of 'X equals. Redeploying the iApp will not trigger an immediate backup unless the iCall handler is recreated and the first-occurrence value is set to a time before the moment of redeployment. When testing is complete, set the Backup Schedule to the desired ongoing schedule."
message deployment_info_logs "The general log for all iApps is '/var/tmp/scriptd.out'. This iApp adds run logs and errors to '/var/tmp/scriptd.out'. Additionally, this iApp sends run logs (not full error messages) to '/var/log/ltm' (compatible with BIG-IP Remote Logging configuration)."
}
section backup_type {
choice backup_type_select display "xlarge" { "UCS (User Configuration Set)", "SCF (Single Configuration File)" }
optional ( backup_type_select == "SCF (Single Configuration File)" ) {
message backup_help_scf "WARNING: Beware of choosing SCF file as not all configuration is included therein. Please check out SOL13408 (http://support.f5.com/kb/en-us/solutions/public/13000/400/sol13408.html) for more information."
}
optional ( backup_type_select == "UCS (User Configuration Set)" ) {
choice backup_passphrase_select display "small" { "Yes", "No" }
optional ( backup_passphrase_select == "Yes" ) {
message backup_help_passphrase "WARNING: Losing the passphase will render the archives unusable. The encrypted UCS archive will be a PGP encoded file, *not* simply a tar.gz with a password on it."
password backup_passphrase required display "large"
}
choice backup_includeprivatekeys display "small" { "Yes", "No" }
optional ( backup_includeprivatekeys == "No" ) {
message backup_help_privatekeys "WARNING: A UCS archive that does not contain the private keys CANNOT be used for restoring the device. It should be used for transfers to external services to whom you do not wish to disclose the private keys."
}
}
}
section backup_schedule {
choice frequency_select display "large" { "Disable", "Every X Minutes", "Every X Hours", "Every X Days", "Every X Weeks", "Every X Months", "Custom" }
optional ( frequency_select == "Every X Minutes" ) {
editchoice everyxminutes_value default "30" display "small" { "1", "2", "5", "10", "15", "20", "30", "45", "60" }
}
optional ( frequency_select == "Every X Hours" ) {
editchoice everyxhours_value default "1" display "small" { "1", "2", "3", "4", "6", "12", "24" }
choice everyxhours_min_select display "small" tcl {
for { set x 0 } { $x < 60 } { incr x } {
append mins "$x\n"
}
return $mins
}
}
optional ( frequency_select == "Every X Days" ) {
editchoice everyxdays_value default "1" display "small" { "1", "2", "3", "4", "5", "7", "14" }
string everyxdays_time required display "medium"
}
optional ( frequency_select == "Every X Weeks" ) {
editchoice everyxweeks_value default "1" display "small" { "1", "2", "3", "4", "5", "7", "14" }
choice everyxweeks_dow_select default "Sunday" display "medium" { "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday" }
string everyxweeks_time required display "small"
}
optional ( frequency_select == "Every X Months" ) {
editchoice everyxmonths_value default "1" display "small" { "1", "2", "3", "6", "12" }
choice everyxmonths_dom_select display "small" tcl {
for { set x 1 } { $x < 31 } { incr x } {
append days "$x\n"
}
return $days
}
string everyxmonths_time required display "small"
}
optional ( frequency_select == "Custom" ) {
multichoice custom_dow_select default {"Sunday"} display "medium" { "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday" }
string custom_time required display "small"
}
}
optional ( backup_schedule.frequency_select != "Disable" ) {
section destination_parameters {
choice protocol_enable display "xlarge" { "On this F5", "Remotely via SCP/SFTP", "Remotely via SMB/CIFS", "Remotely via FTP" }
optional ( protocol_enable == "Remotely via SCP/SFTP") {
message scp_sftp_help "A connection to an SSH server can be establish using both SCP and SFTP. SCP is more efficient for copying files to a remote network destination while, for interactive sessions, the SFTP protocol offers more features. This iApp uses SCP."
string scp_remote_server required display "medium"
message scp_remote_server_help "The Destination can be an IP address or an FQDN. DNS must be configured and functional on this BIG-IP (and HA peers) for an FQDN to work."
message scp_remote_server_help2 "IMPORTANT: Check '/root/.ssh/known_hosts' on each BIG-IP (including HA peers) to ensure the Destination above is listed. If using an FQDN, the name (not just the IP) must be in known_hosts. On each BIG-IP that does not list the Destination (including HA peers), connect directly to the Destination using the scp or ssh command. You will be asked to verify the 'RSA key fingerprint'. Entering 'yes' will store the fingerprint in '/root/.ssh/known_hosts' and allow subsequent connections without further verification. If you run into cipher errors, you may need to add '-c aes128-ctr' or an appropriate cipher (see the help under Cipher below)."
message scp_source_help "Connections to the Destination will be sourced from a non-floating Self IP or from the Management IP based on L2/L3 networking. If the Destination is in the same subnet as a Self IP or the Management IP, you cannot easily affect the source IP. If the Destination must be routed, you can manipulate the source IP by creating a TMM route or Management Route to force the L3 next-hop/gateway (the BIG-IP will use a source IP in the same subnet as the L3 next-hop/gateway)."
choice scp_stricthostkeychecking default "Yes" display "large" { "Yes", "No (INSECURE)" }
optional ( scp_stricthostkeychecking == "No (INSECURE)" ) {
message scp_stricthostkeychecking_warning1 "WARNING: Selecting 'No (INSECURE)' will ignore certificate verification for connections this iApp makes to the server configured above. Backups could be copied to an unintended server, including one owned by a bad actor."
}
message scp_stricthostkeychecking_help1 "It is MOST SECURE to select Yes, which is the SCP/SSH default setting and which will not allow connections to unknown servers. A server is considered 'unknown' until an SSH key fingerprint has been verified, or if the destination SSL certificate changes and the fingerprint no longer matches."
optional ( scp_stricthostkeychecking == "Yes" ) {
message scp_stricthostkeychecking_help2 "Selecting 'No (INSECURE)' will ignore certificate verification for connections this iApp makes to the server configured above."
message scp_stricthostkeychecking_trouble1 "TROUBLESHOOTING: If the SCP script fails with a 'Host key verification failed' or 'No RSA host key is known for' error (which can viewed in /var/tmp/scriptd.out after deploying this iApp), review the IMPORTANT steps (under Destination IP) above regarding the known_hosts file to resolve the issue. Also, review additional troubleshooting notes."
message scp_stricthostkeychecking_trouble2 "TROUBLESHOOTING: If the SCP script fails with a 'WARNING: REMOTE HOST IDENTIFICATION HAS CHANGED!' error (which can viewed in /var/tmp/scriptd.out after deploying this iApp), the certificate on the destination server has changed. This could mean 1) The certificate was updated legitimately, or 2) There is an IP conflict and the script is connecting to the wrong server, or 3) the destination server was replaced or rebuilt and has a new certificate, or 4) a bad actor is intercepting the connection (man-in-the-middle) and the script is rightly warning you to not connect. Investigate the destination server before proceeding."
}
string scp_remote_username required display "medium"
password scp_sshprivatekey required display "large"
message scp_encrypted_field_storage_help "Private key must be non-encrypted and in 'OpenSSH' base64 format. As an example run 'ssh-keygen -t rsa -b 4096 -C f5_backups' from the BIG-IP CLI, step through the questions, and view the resulting private key (by default ssh-keygen will save the key to ~/.ssh/id_rsa)."
message scp_encrypted_field_storage_help2 "If the Destination Server supports it, you may optionally run 'ssh-copy-id -i /root/.ssh/id_rsa.pub -o Ciphers=aes128-ctr username@destination' (with relevant values) to add the public key to the Destination Server's authorized_keys file (this only needs to be done once per unique key--not from every BIG-IP)."
message scp_encrypted_field_storage_help3 "Passwords and private keys are stored in an encrypted format. The salt for the encryption algorithm is the F5 cluster's Master Key. The master key is not shared when exporting a qkview or UCS, thus rendering your passwords and private keys safe if a backup file were to be stored off-box."
editchoice scp_cipher display "xlarge" { "aes128-ctr", "aes192-ctr", "aes256-ctr", "[email protected]", "[email protected]" }
message scp_cipher_help "This can often be left blank but, depending on the version of F5 TMOS and the ssh configuration of the destination server, there may be no matching ciphers resulting in a 'no matching cipher found' error (which can viewed in /var/tmp/scriptd.out after deploying this iApp or it can be tested/demonstrated by attempting an scp or ssh connection from this device to the destination server). Find the word 'server' in the error and note the ciphers listed; select one of these ciphers from the list above or paste in one not listed. This can be tested by attempting 'ssh -c aes128-ctr username@destination' (with appropriate cipher) from this device's CLI."
string scp_remote_directory display "medium"
message scp_remote_directory_help "Full path without a trailing slash (e.g. '/home/user1/f5_backups/prod')."
}
optional ( protocol_enable == "Remotely via SMB/CIFS") {
string smb_remote_server required display "medium"
message smb_remote_server_help "The Destination can be an IP address or an FQDN. DNS must be configured and functional on this BIG-IP (and HA peers) for an FQDN to work."
message smb_remote_server_help2 "Ensure this Destination IP is reachable on port 139."
message smb_source_help "Connections to the Destination will be sourced from a non-floating Self IP or from the Management IP based on L2/L3 networking. If the Destination is in the same subnet as a Self IP or the Management IP, you cannot easily affect the source IP. If the Destination must be routed, you can manipulate the source IP by creating a TMM route or Management Route to force the L3 next-hop/gateway (the BIG-IP will use a source IP in the same subnet as the L3 next-hop/gateway)."
string smb_remote_domain required display "medium"
message smb_remote_domain_help "Start by entering the NetBIOS/Pre-Windows 2000 domain name; the fully qualified DNS domain name may work or be required in some environments."
string smb_remote_username required display "medium"
password smb_remote_password display "medium"
message smb_remote_password_help "Some special (non-alphanumeric) characters within passwords may need to be escaped (add a backslash before each special character as you input the password). RECOMMENDATION: Enter the password as-is (no escaping) and test. If the backup fails due to invalid credentials or some script error (possibly caused by an unescaped character) try escaping one non-alphanumeric at a time and re-testing."
message smb_remote_password_help2 "Passwords and private keys are stored in an encrypted format. The salt for the encryption algorithm is the F5 cluster's Master Key. The master key is not shared when exporting a qkview or UCS, thus rendering your passwords and private keys safe if a backup file were to be stored off-box."
string smb_remote_path required display "medium"
message smb_remote_path_help "SMB share on a remote server. Do not include leading and trailing slashes. If the full share path is //SERVER/SHARE, enter SHARE in this field. If the full share path is //SERVER/PATH/SHARE, enter PATH/SHARE in this field."
string smb_remote_directory display "medium"
message smb_remote_directory_help "Relative path inside the SMB share to copy the file. Leave this field empty to store in root of SMB share. Include one leading slash and no trailing slashes. If the target directory is //SERVER/SHARE/PATH/DIRECTORY, enter /PATH/DIRECTORY in this field."
string smb_local_mountdir required default "/var/tmp/cifs" display "medium"
message smb_local_mountdir_help "Read-Write path on local F5 where SMB share will be mounted. Include one leading slash and no trailing slashes, for example /var/tmp/cifs"
}
optional ( protocol_enable == "Remotely via FTP") {
string ftp_remote_server required display "medium"
message ftp_remote_server_help "The Destination can be an IP address or an FQDN. DNS must be configured and functional on this BIG-IP (and HA peers) for an FQDN to work."
message ftp_source_help "Connections to the Destination will be sourced from a non-floating Self IP or from the Management IP based on L2/L3 networking. If the Destination is in the same subnet as a Self IP or the Management IP, you cannot easily affect the source IP. If the Destination must be routed, you can manipulate the source IP by creating a TMM route or Management Route to force the L3 next-hop/gateway (the BIG-IP will use a source IP in the same subnet as the L3 next-hop/gateway)."
string ftp_remote_username required display "medium"
password ftp_remote_password display "medium"
message ftp_encrypted_field_storage_help "Passwords and private keys are stored in an encrypted format. The salt for the encryption algorithm is the F5 cluster's Master Key. The master key is not shared when exporting a qkview or UCS, thus rendering your passwords and private keys safe if a backup file were to be stored off-box."
string ftp_remote_directory display "medium"
message ftp_remote_directory_help "Full path without a trailing slash (e.g. '/home/user1/f5_backups/prod'), or relative directory name inside the user's home directory without leading and trailing slashes (e.g. 'f5_backups' or 'f5_backups/prod')."
}
editchoice filename_format display "xxlarge" tcl {
set host [tmsh::get_field_value [lindex [tmsh::get_config sys global-settings] 0] hostname]
set formats ""
append formats {%Y%m%d%H%M%S_${host} => }
append formats [clock format [clock seconds] -format "%Y%m%d%H%M%S_${host}"]
append formats "\n"
append formats {%Y%m%d_%H%M%S_${host} => }
append formats [clock format [clock seconds] -format "%Y%m%d_%H%M%S_${host}"]
append formats "\n"
append formats {%Y%m%d_${host} => }
append formats [clock format [clock seconds] -format "%Y%m%d_${host}"]
append formats "\n"
append formats {${host}_%Y%m%d%H%M%S => }
append formats [clock format [clock seconds] -format "${host}_%Y%m%d%H%M%S"]
append formats "\n"
append formats {${host}_%Y%m%d_%H%M%S => }
append formats [clock format [clock seconds] -format "${host}_%Y%m%d_%H%M%S"]
append formats "\n"
append formats {${host}_%Y%m%d => }
append formats [clock format [clock seconds] -format "${host}_%Y%m%d"]
append formats "\n"
return $formats
}
message filename_format_help "You can select one, or create your own with all the [clock format] wildcards available in the tcl language, plus ${host} for the hostname. (http://www.tcl.tk/man/tcl8.6/TclCmd/clock.htm)"
optional ( protocol_enable == "On this F5" ) {
choice pruning_enable display "small" { "No", "Yes" }
optional ( pruning_enable == "Yes" ) {
editchoice keep_amount display "small" { "1", "2", "3", "4", "5", "6", "7", "8", "9", "10" }
message pruning_help "Warning: if you decide to manually create a backupfile in the default directory, the automatic pruning will clean it if it doesn't match the 'newest X files' in that directory."
}
}
}
}
text {
deployment_info "Deployment Information"
deployment_info.deployment_info_first_time "First Time Deployment:"
deployment_info.deployment_info_updates "Testing the iApp:"
deployment_info.deployment_info_logs "Logging:"
backup_type "Backup Type"
backup_type.backup_type_select "Select the type of backup:"
backup_type.backup_passphrase_select "Use a passphrase to encrypt the UCS archive:"
backup_type.backup_passphrase "What is the passphrase you want to use?"
backup_type.backup_includeprivatekeys "Include the private keys in the archives?"
backup_type.backup_help_scf ""
backup_type.backup_help_passphrase ""
backup_type.backup_help_privatekeys ""
backup_schedule "Backup Schedule"
backup_schedule.frequency_select "Frequency:"
backup_schedule.everyxminutes_value "Where X equals:"
backup_schedule.everyxhours_value "Where X equals:"
backup_schedule.everyxhours_min_select "At what minute of each X hours should the backup occur?"
backup_schedule.everyxdays_value "Where X equals:"
backup_schedule.everyxdays_time "At what time on each X days should the backup occur? (Ex.: 15:25)"
backup_schedule.everyxweeks_value "Where X equals:"
backup_schedule.everyxweeks_time "At what time on the chosen day of each X weeks should the backup occur? (e.g. 04:15, 21:30)"
backup_schedule.everyxweeks_dow_select "On what day of each X weeks should the backup should occur:"
backup_schedule.everyxmonths_value "Where X equals:"
backup_schedule.everyxmonths_time "At what time on the chosen day of each X months should the backup occur? (e.g. 04:15, 21:30)"
backup_schedule.everyxmonths_dom_select "On what day of each X months should the backup should occur:"
backup_schedule.custom_time "At what time on each selected day should the backup occur? (e.g. 04:15, 21:30)"
backup_schedule.custom_dow_select "Choose the days of the week the backup should occur:"
destination_parameters "Destination Parameters"
destination_parameters.protocol_enable "Where do the backup files need to be saved?"
destination_parameters.scp_sftp_help "SCP or SFTP?"
destination_parameters.scp_remote_server "Destination:"
destination_parameters.scp_remote_server_help ""
destination_parameters.scp_remote_server_help2 ""
destination_parameters.scp_source_help "Source IP"
destination_parameters.scp_stricthostkeychecking "StrictHostKeyChecking"
destination_parameters.scp_stricthostkeychecking_help1 ""
destination_parameters.scp_stricthostkeychecking_help2 ""
destination_parameters.scp_stricthostkeychecking_trouble1 ""
destination_parameters.scp_stricthostkeychecking_trouble2 ""
destination_parameters.scp_stricthostkeychecking_warning1 ""
destination_parameters.scp_remote_username "Username:"
destination_parameters.scp_sshprivatekey "Copy/Paste the SSH private key to be used for passwordless authentication:"
destination_parameters.scp_encrypted_field_storage_help ""
destination_parameters.scp_encrypted_field_storage_help2 ""
destination_parameters.scp_encrypted_field_storage_help3 ""
destination_parameters.scp_remote_directory "Remote directory for archive upload:"
destination_parameters.scp_remote_directory_help ""
destination_parameters.scp_cipher "Cipher"
destination_parameters.scp_cipher_help ""
destination_parameters.smb_remote_server "Destination:"
destination_parameters.smb_remote_server_help ""
destination_parameters.smb_remote_server_help2 ""
destination_parameters.smb_source_help "Source IP"
destination_parameters.smb_remote_username "Username:"
destination_parameters.smb_remote_domain "Domain Name:"
destination_parameters.smb_remote_domain_help ""
destination_parameters.smb_remote_password "Password:"
destination_parameters.smb_remote_password_help ""
destination_parameters.smb_remote_password_help2 ""
destination_parameters.smb_remote_path "SMB/CIFS share name:"
destination_parameters.smb_remote_path_help ""
destination_parameters.smb_remote_directory "Target path inside SMB Share:"
destination_parameters.smb_remote_directory_help ""
destination_parameters.smb_local_mountdir "Local mount point:"
destination_parameters.smb_local_mountdir_help ""
destination_parameters.ftp_remote_username "Username:"
destination_parameters.ftp_remote_password "Password:"
destination_parameters.ftp_encrypted_field_storage_help ""
destination_parameters.ftp_remote_server "Destination:"
destination_parameters.ftp_remote_server_help ""
destination_parameters.ftp_source_help "Source IP"
destination_parameters.ftp_remote_directory "Set the remote directory the archive should be copied to:"
destination_parameters.ftp_remote_directory_help ""
destination_parameters.filename_format "Select the filename format:"
destination_parameters.filename_format_help ""
destination_parameters.pruning_enable "Activate automatic pruning?"
destination_parameters.pruning_help ""
destination_parameters.keep_amount "Amount of files to keep at any given time:"
}
}
role-acl { admin manager resource-admin }
run-as none
}
}
description none
ignore-verification false
requires-bigip-version-max none
requires-bigip-version-min 11.5.4
requires-modules { ltm }
signing-key none
tmpl-checksum none
tmpl-signature none
}