Author Topic: Workspace-Based Backup Locations  (Read 1018 times)


  • Senior Community Member
  • Posts: 123
  • Hero Points: 0
Workspace-Based Backup Locations
« on: July 20, 2018, 04:51:22 pm »
All of my work is done over networks so the file paths (and backup directory path) always contain a network name.

Currently my backup directory is in the network where I do most of my work. However, it would be real nice if I could set up the backup directory to be located on the network of the current workspace.

Is there any way to set up different backup directories for different workspaces?

Thank  you,



  • Senior Community Member
  • Posts: 2484
  • Hero Points: 325
Re: Workspace-Based Backup Locations
« Reply #1 on: July 21, 2018, 04:07:31 am »
Assuming you're using what you showed here - "create backup file on first save",15783.msg60208.html#msg60208

it seems you have "backup location" set to "global nested directories".  I guess this means that your backups will all be on the same drive but separated into nested folders according to the path of the file being saved.  Is that what's currently happening?

If you click the help button when you're in the options dialog you'll see that there's options "same directory as *.bak" and "use child directory"  - both of which co-locate the backup with the file being saved.

There's some other ways.  There's an environment variable VSLICKBACKUP that you can set.  In project properties on the open tab you should be able to have
allowing you to choose a specific backup folder when the project is made active.  I haven't tested this.

Another way is to use a customized version of the save_file function  - type fp save_file on the slick command line.  save_file is described as "a hook function that the user may replace".  Below is one version of save_file that I use.  The commented lines with <<<<<<<<<<< are some debugging code that I added  - the "say" function outputs text to the vs debug window.  The following line
//set_env("VSLICKBACKUP", strip_filename(_workspace_filename, 'N') :+ "/backup1" );
sets VSLICKBACKUP to a "backup1" folder in the workspace file folder  - I assume this worked but I don't remember now.  You can use the "strip-filename" function to get the drive of the file being saved.
Towards the end of the save_file function below, you'll see I'm making two extra copies of the file (because it amuses me) - one to google drive and one to one-drive.

Another thing you can do is use the _cbsave_ callback.
Yet another option is to use a Windows drive mapping and set the drive map in project properties.
I suspect you can also use an environment variable %whatever% in the "backup directory path" setting - not sure if this works.

Unlike you I have backup history enabled which means I don't get to set "backup location"  - but I have "backup directory path" set to "./SlickBackups/" which means I get lots of child folders called SlickBackups.

Code: [Select]
_str save_file(_str filename,_str options)
#if 0
   int renumber_flags=numbering_options();
   if (renumber_flags&VSRENUMBER_AUTO) {
      if (renumber_flags&VSRENUMBER_COBOL) {
      if (renumber_flags&VSRENUMBER_STD) {

   //say("Save " :+ options :+ "  " :+ filename);              <<<<<<<<<<<<<<
   //set_env("VSLICKBACKUP", "C:/GP/TEMP/backups");      <<<<<<<<<<<<<<<<<
   //set_env("VSLICKBACKUP", strip_filename(filename,'N') :+ "/BACK1" );        <<<<<<<<<<<<<<
   //set_env("VSLICKBACKUP", strip_filename(_workspace_filename, 'N') :+ "/backup1" );  <<<<<<<<<<

   typeless status=_save_file(options " "_maybe_quote_filename(filename));
   if (!status && file_eq(strip(filename,'B','"'),p_buf_name)) {
      if (p_modified_temp_name!='') {
#if 1
      //10:51am 7/3/1997
      //Dan modified for auto-tagging
      if (def_autotag_flags2&AUTOTAG_ON_SAVE) {
         //messageNwait(nls('got here'));
   _str pa = 'C:\Users\GP\Google Drive\slick\copy-on-save\' :+ strip_filename(filename,'DN');
   if (!path_exists(pa)) {
      int result = make_path(pa);
      if (result) {
         _message_box("slick backup make path failed : " :+ result :+ pa);
         return status;

   int result2 = copy_file(filename, pa :+ strip_filename(filename,'P'));

   if (result2 != 0) {
      _message_box("slick backup main google drive copy failed " :+ (_str)(result2));

   int result = copy_file(filename, 'C:\Users\GP\OneDrive\slick-copy-on-save\' :+ strip_filename(filename,'P'));

   if (result != 0) {
      _message_box("slick backup main one drive copy failed " :+ (_str)(result));



  • Senior Community Member
  • Posts: 123
  • Hero Points: 0
Re: Workspace-Based Backup Locations
« Reply #2 on: July 23, 2018, 05:45:44 pm »
You are correct about my settings. I tried the .bak and child directory method first but found I was constantly fighting with version control SW because it would think all the .bak files were new files that needed to be considered. I switched to the nested directories setting because it allowed me to keep the files on the server without causing version control issues.

I work on SlickEdit on the PC but my files are all on various Unix directories on different servers around the country.



  • Senior Community Member
  • Posts: 141
  • Hero Points: 11
  • -Tim
Re: Workspace-Based Backup Locations
« Reply #3 on: September 26, 2018, 09:33:39 pm »
I have a similar need to keep backups tied to the project, and have used the "./.slickeditBackup" path selection in the past, which makes for zillions of backup directories. I tried Graeme's solution of using the VSLICKBACKUP environment variable in the project settings:
Code: [Select]
SET VSLICKBACKUP="%rw/.slickeditBackups"
Which seems to work. Though I haven't tested it much yet.

Wanting to make this a universal solution, not per-project, I tried entering the same value in the backup options setting for "Backup directory path": "%rw/.slickeditBackups", with no workspace open. Then I opened a workspace without a VSLICKBACKUP value. This did not work as expected. Slickedit put a directory "%rw" in the project working directory, and then put a subdirectory ".slickeditBackups" in that directory, then put the backups there.