util::backup_file (public)
util::backup_file -file_path file_path \ [ -backup_suffix backup_suffix ]
Defined in packages/acs-tcl/tcl/utilities-procs.tcl
Backs up (move) the file or directory with given path to a file/directory with a backup suffix. Will avoid overwriting old backup files by adding a number to the filename to make it unique. For example, suppose you are backing up /web/my-server/packages/my-package/file.txt and the file has already been backed up to /web/my-server/packages/my-package/file.txt.bak. Invoking this proc will then generate the backup file /web/my-server/packages/my-package/file.txt.bak.2
- Switches:
- -file_path (required)
- -backup_suffix (optional, defaults to
".bak"
)- The suffix to add to the backup file.
- Author:
- Peter Marklund
- Partial Call Graph (max 5 caller/called nodes):
- Testcases:
- No testcase defined.
Source code: # Keep generating backup paths until we find one that doesn't already exist set backup_counter 1 while {1} { if { $backup_counter == 1 } { set backup_path "${file_path}${backup_suffix}" } else { set backup_path "${file_path}${backup_suffix}.${backup_counter}" } if { ![ad_file exists $backup_path] } { # We found a non-existing backup path break } incr backup_counter } #exec "mv" "$file_path" "$backup_path" file rename -- $file_path $backup_pathXQL Not present: PostgreSQL, Oracle Generic XQL file: packages/acs-tcl/tcl/utilities-procs.xql