Re: Turning off remote backups

Michael Albinus <[email protected]>
Newsgroups gmane.emacs.tramp
Message-ID <[email protected]>
Ben Sturmfels <[email protected]> writes:

> Hi folks,

Hi Ben,

> When using TRAMP to edit a remote WordPress wp-config.php file, I'd
> like to prevent backup files being created, since the adjacent
> wp-config.php~ could expose passwords if Apache serves it directly
> without being interpreted as PHP. In the TRAMP documentation, "4.23
> Auto-save, File Lock and Backup configuration", it says:
>
>> To “turn off” the backup feature for remote files and stop TRAMP from
>> saving to the backup directory, use this:
>>
>>      (add-to-list 'backup-directory-alist
>>                   (cons tramp-file-name-regexp nil))
>
> This sounded like what I wanted, but when I ran this Elisp on a fresh `emacs -Q` then opened, modified and saved a remote file, a backup file was still created.

Strange. I've checked the git history, and it looks like this example
was added to the manual in 2003. Likely, it worked those days (Emacs 21
time). I've never used the code snippet myself.

So I've decided to fix it. I made a small patch to Tramp, pushed to the
Tramp and Emacs repositories. Now, the manual reads

--8<---------------cut here---------------start------------->8---
   In case you do not want to use backup files for remote files, use
connection-local variable ‘make-backup-files’ (*note (emacs)Connection
Variables::) like this:

     (connection-local-set-profile-variables
      'no-remote-backup-files '((make-backup-files . nil)))

     (connection-local-set-profiles
      '(:application tramp) 'no-remote-backup-files)

Disabling backups can be targeted to just the ‘su’ and ‘sudo’ methods:

     (connection-local-set-profiles
      '(:application tramp :protocol "su") 'no-remote-backup-files)

     (connection-local-set-profiles
      '(:application tramp :protocol "sudo") 'no-remote-backup-files)
--8<---------------cut here---------------end--------------->8---

> Thanks for your work on TRAMP. I find it incredibly useful!

This patch will also be available on GNU ELPA with Tramp 2.8.2.2,
scheduled for the end of this month.

> Regards,
> Ben

Best regards, Michael.
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.