jEdit Community - Resources for users of the jEdit Text Editor
FTP Plugin + Backups?
Submitted by sandy on Saturday, 3 April, 2004 - 21:59
Hello...I'm new to jEdit but really enjoying it. For school I do a lot of work on a remote server, and while I like using the FTP plugin to directly edit these files, I'd also like to have jEdit automatically backup to my workstation (the school server is notoriously unreliable). I set in the global options for jEdit to automatically backup upon every save to a specified backup directory on my local machine, but it doesn't seem to be working for files opened with the FTP plugin. Am I missing something? It's also not creating the directory on the remote server, as far as I can tell. Thanks!
Comment viewing options
Select your preferred way to display the comments and click 'Save settings' to activate your changes.
Macro do do backup for the FTP plugin
by fraktal on Wed, 25/06/2008 - 20:30
Hi guys,

I had the same issue and did a little macro to do a backup everytime you save a file, including on FTP.

Save the file below in your jEdit macro directory, and assign this macro to CTRL+S shortcut.

Don't forget to disable any jEdit normal backup setting you may have, otherwise, file are going to be backup twice!

---------save-backup.bsh------------
//backup path
BackupPath = "C:\\path\\to\\backups\\"; //don't forget the trailing \\

path = buffer.getDirectory();
path = path.replaceFirst("ftp://", "");
path = path.replace('/', '\\');
path = path.replaceAll(":", ""); //this is for local files (c:\ -> c\

//todo : remove other unwanted characters ?

path = BackupPath + path;

(new File(path)).mkdirs(); //create the backup directory if it doesn't exist

path = path + buffer.getName();

buffer.save(view,path,false); //save copy
VFSManager.waitForRequests();
buffer.save(view,null,true);

----------end of file--------------

Warning : this macro works for me, but it hasn't been extensively tested, and problems may arise in some special cases... For example, for protocols other than ftp:// (sftp, etc...), and for special chars in the path... Be warned ! Smiling
 
Backup each save
by bdiaconu on Thu, 07/01/2010 - 09:24
Thank you very much for giving the solution.

I wanted a file for each save. I've done it using timestamp in format yyyymmddhhmmss.
(attention: if system date is changed, it's possible some files to be overwritten)

//---------save-backup.bsh------------

import java.util.Calendar;
import java.text.SimpleDateFormat;

//backup path
BackupPath = "Z:\\Jedit_backups\\"; //don't forget the trailing \\

Calendar cal = Calendar.getInstance();
SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHHmmss");
timestamp = sdf.format(cal.getTime());


path = buffer.getDirectory();
path = path.replaceFirst("ftp://", "");
path = path.replace('/', '\\');
path = path.replaceAll(":", ""); //this is for local files (c:\ -> c\

//todo : remove other unwanted characters ?

path = BackupPath + path;

(new File(path)).mkdirs(); //create the backup directory if it doesn't exist


path = path + buffer.getName() + '_' + timestamp;
// buffer.getLastModified(); - fails for FTP: puts 0 all the time

buffer.save(view,path,false); //save copy
VFSManager.waitForRequests();
buffer.save(view,null,true);

//Macros.message(view, "Backup done in " + BackupPath);
view.getStatus().setMessageAndClear("Macro save-backup.bsh: Backup done in " + BackupPath);

//--------end

- put this in a file, eg save-backup.bsh
- put the file in a subfolder (eg Files) of 'macros' folder from jedit installation
- open jedit
- Utilities > Global Options > Shortcuts
- enter, in the 'filter' field, the name of the file
- click in the 'Primary shortcut'
- press CTRL + s (the 'Save' shortcut)
- accept the override
- in 'Saving & Backup' put the 'Max number of backups' to 0 (zero - it disables other backups)
- press OK to save changes
(done in Jedit 4.3)
Currently, each VFS must impl
by Anonymous on Sun, 04/04/2004 - 11:46
Currently, each VFS must implement 'backup' and FTP doesn't. 4.3 might include built-in backup.
 
Ah, well that's disappointing
by sandy on Sun, 04/04/2004 - 17:18
Ah, well that's disappointing. Thanks for clearing that up though!
User login
Browse archives
« April 2024  
MoTuWeThFrSaSu
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
 
Poll
Are you interested in language packs for jEdit?
Yes, and I could help maintain translations
26%
Yes, I'd like to have translations
32%
Indifferent
35%
No, that'd be bad (please comment)
7%
Total votes: 1093
Syndication
file   ver   dls
German Localization light   4.4.2.1   82347
Context Free Art (*.cfdg)   0.31   46055
JBuilder scheme   .001   18494
BBEdit scheme   1.0   18115
ColdFusion scheme   1.0   18023
R Edit Mode - extensive version   0.1   17472
Advanced HTML edit mode   1.0   16205
Matlab Edit Mode   1.0   16068
jEdit XP icons   1.0   15229
XP icons for jEdit   1.1   14292