1 (edited by apmuthu 12/20/2014 10:47:25 am)

Topic: Renaming Backup File Feature Mod

I have just made a modification of the admin/backups.php file to allow for renaming of backup files to .sql or .gz files after stripping all spaces (and periods for other extensions, forcing an .sql.gz extension for such ones).

@joe: you can include it in the core.

--- old/admin/backups.php    Sat Dec 20 14:35:56 2014
+++ new/admin/backups.php    Sat Dec 20 15:43:18 2014
@@ -142,6 +142,26 @@
         display_error(_("Select backup file first."));
 }
 
+if (get_post('rendump')) {
+    if ($backup_name) {
+        $rename_file = str_replace(" ", "", trim(get_post('comments')));
+        if (strlen($rename_file) > 0) {
+
+            $file_extn = pathinfo($rename_file, PATHINFO_EXTENSION);
+            if (!in_array($file_extn, Array("sql","gz")))
+                $rename_file = str_replace(".", "", $rename_file) . '.sql.gz';
+            $rename_path = BACKUP_PATH . $rename_file;
+
+            if (rename($backup_path, $rename_path)) {
+                display_notification($backup_name . " : " . _("File successfully renamed.")." "
+                    . _("New Filename") . ": " . $rename_path);
+                $Ajax->activate('backups');
+            } else display_error(_("Can't rename backup file."));
+
+        } else display_error($rename_file . " : " . _("Enter valid new file name to rename backup file."));
+    } else display_error(_("Select backup file first."));
+}
+
 if (get_post('deldump')) {
     if ($backup_name) {
         if (unlink($backup_path)) {
@@ -191,6 +211,8 @@
     start_table();
     submit_row('view',_("View Backup"), false, '', '', false);
     submit_row('download',_("Download Backup"), false, '', '', false);
+    submit_row('rendump',_("Rename Backup"), false, '','', 'process');
+    submit_js_confirm('rendump',_("You are about to rename database backup file.\nDo you want to continue?"));
     submit_row('restore',_("Restore Backup"), false, '','', 'process');
     submit_js_confirm('restore',_("You are about to restore database from backup file.\nDo you want to continue?"));

Pushed to my github repo till inclusion into core.

Post's attachments

FA_Backup_Rename_Patch.zip 22.8 kb, file has never been downloaded. 

You don't have the permssions to download the attachments of this post.

Re: Renaming Backup File Feature Mod

Screenshot of the new functionality is attached. The New file name needs to be entered into the comments section of the Create Backup Column.

Post's attachments

FA_Rename_Backup_ss3.png 17.7 kb, file has never been downloaded. 

You don't have the permssions to download the attachments of this post.

Re: Renaming Backup File Feature Mod

Could you explain me what is case use of the proposed feature?
You can (and should) always name the uploaded file properly, so why we should complicate the application interface with this additional option here? Using  'mv' command or 'Rename' option in your windowed OS is quite easy.

Janusz

4 (edited by apmuthu 12/20/2014 05:03:43 pm)

Re: Renaming Backup File Feature Mod

Actually, I was testing out various means of directly populating the database with suppliers data when I needed to rollback several times to different snapshots. The standard naming feature has just the database name, table prefix and date and time (hh:mm only). Twice, when backups were done within the same integral minute, the old one was overwritten.

Also providing some sort of a suffix to the file name part (not the extension) would be human readable.

We can use several linux and dos commands to achieve the same but when done within the Web UI it seemed cool and useful. Many times we may have the same named file from different VPSes which auto synch to a single folder with similar names and even if the date and time portions are different, the files are easy to get confused with one another.

It also helps avoid having to give FTP and shell / SSH access to the end user.

QED.

Re: Renaming Backup File Feature Mod

A set of screenshots for this feature are now in my FA Support Wiki.

Re: Renaming Backup File Feature Mod

Additional mods are now available to execute system shell commands.
View the commit.