Backup Directory

88 views
Skip to first unread message

Christopher

unread,
Mar 7, 2026, 7:44:56 AM (2 days ago) Mar 7
to vim_use
I'm trying to setup a backup directory; "backupdir"=//etc/.backup within my vimrc although; no file is being written to this directory ?

badli al rashid

unread,
Mar 7, 2026, 12:49:30 PM (2 days ago) Mar 7
to vim...@googlegroups.com
hi crestchristopher,

try with your home folder. 

Sent from Gmail

On Sat, Mar 7, 2026, 20:45 Christopher <crestchr...@gmail.com> wrote:
I'm trying to setup a backup directory; "backupdir"=//etc/.backup within my vimrc although; no file is being written to this directory ?

--
--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+u...@googlegroups.com.
To view this discussion visit https://groups.google.com/d/msgid/vim_use/2d4c7c1e-9437-4c49-aca8-bf1f2dadb3c1n%40googlegroups.com.

Christian Brabandt

unread,
Mar 7, 2026, 12:54:03 PM (2 days ago) Mar 7
to vim...@googlegroups.com

On Sa, 07 Mär 2026, Christopher wrote:

> I'm trying to setup a backup directory; "backupdir"=//etc/.backup
> within my vimrc although; no file is being written to this directory ?

Please show what exactly you set. You may also need to :set backup to
keep the backup file available after the file was successfully written.

See :h backup-table

Thanks,
Christian
--
Now my EMOTIONAL RESOURCES are heavily committed to 23% of the SMELTING
and REFINING industry of the state of NEVADA!!

Eric Marceau

unread,
Mar 7, 2026, 5:19:25 PM (2 days ago) Mar 7
to vim...@googlegroups.com
Also, I think you may need to correct what I see as a mis-type, "//" at start of string.

Suggest you try using

	"backupdir"=/etc/.backup

Eric

Christopher

unread,
Mar 7, 2026, 8:56:51 PM (2 days ago) Mar 7
to vim_use
I tried your suggestion but I don't see any files in the .backup folder ?

Christopher

unread,
Mar 7, 2026, 9:00:36 PM (2 days ago) Mar 7
to vim_use
Why don't I see any backup files, no matter what file I work with ?

Riza Dindir

unread,
Mar 7, 2026, 10:28:21 PM (2 days ago) Mar 7
to vim...@googlegroups.com
Hello Christopher,

As Eric Marceau pointed out, the double forward slash (//) in the path ("backupdir"=//etc/.backup) might be a problem.

Also the double quotes in "backupdir"=//etc/.backup might be a problem. I would use "set backupdir=/etc/.backup" (without the double quotes) in the ~/.vimrc file or wherever your rc file is. I have something similar in my settings file: "set bakupdir=/tmp" (without the double quotes).

The other thing might be that you have to create the /etc/.backup directory, and you might need write permissions to that directory. It is odd to use the /etc directory for this IMHO. It might be a good idea to move this to the home folder of your choosing (as Badli al Rashid has suggested). This can be something like ~/tmp/.backup or something else...

Regards

jr

unread,
Mar 8, 2026, 1:00:45 AM (yesterday) Mar 8
to vim...@googlegroups.com
hi,

On Sun, 8 Mar 2026 at 03:28, Riza Dindir <riza....@gmail.com> wrote:
> As Eric Marceau pointed out, the double forward slash (//) in the path ("backupdir"=//etc/.backup) might be a problem.
>
> Also the double quotes in "backupdir"=//etc/.backup might be a problem. I would use "set backupdir=/etc/.backup" (without the double quotes) in the ~/.vimrc file or wherever your rc file is. I have something similar in my settings file: "set bakupdir=/tmp" (without the double quotes).
>
> The other thing might be that you have to create the /etc/.backup directory, and you might need write permissions to that directory. It is odd to use the /etc directory for this IMHO. It might be a good idea to move this to the home folder of your choosing (as Badli al Rashid has suggested). This can be something like ~/tmp/.backup or something else...

just to add, conventionally '/etc' is a system directory and a
non-root user would be permitted to read, not write.

--
regards, jr.

You have the right to free speech, as long as you're not dumb enough
to actually try it.
(The Clash 'Know Your Rights')

this email is intended only for the addressee(s) and may contain
confidential information. if you are not the intended recipient, you
are hereby notified that any use of this email, its dissemination,
distribution, and/or copying without prior written consent is
prohibited.

Christopher

unread,
Mar 8, 2026, 8:58:01 AM (yesterday) Mar 8
to vim_use
It's possible I should be asking, how does it backup.In other words, must I start vim and write something and it will backup to the folder in this case ".backup" ? Or regardless what file it open, it will backup to this folder. Otherwise so it's clear if it's a permissions issue. Currently the /etc/.backup directories both can read and write for the user. 

Christopher

unread,
Mar 8, 2026, 8:59:57 AM (yesterday) Mar 8
to vim_use
I understand the permissions issues. How should it backup to begin with, as I mentioned to someone else. I've started Vim and decided to write and then saved with a file name. I then exited Vim and there was no file in the .backup folder ?

Riza Dindir

unread,
Mar 8, 2026, 10:56:29 AM (yesterday) Mar 8
to vim...@googlegroups.com
As far as I know, whenever you write something to the file that you are editing, and the backup is enabled (writebackup, and backup I believe are the settings, you will have to check with the documentation) and the backupdir is set, it will write to that directory.

And the /etc folder is a system directory, and you might want to keep these folders clean/clear of backups. You could create a ~/.backup folder in your home directory, or maybe you can use /tmp/.backup, or you could use /var/run/.backup (as per the Filesystem Hierarchy Standard). /etc is used for host system specific configuration (if you care about the FHS). But again there is nothing that says you can not change the permissions of the /etc directory and use that for your own purposes.

Regards


Riza Dindir

unread,
Mar 8, 2026, 11:00:41 AM (yesterday) Mar 8
to vim...@googlegroups.com
Please check your settings if you have enabled backups (and set the directory (backupdir) correctly. I am not sure, but you might set the permissions in the parent directories too.

Please also read the help files (:help backup). You must set backup and writebackup settings according to your needs. There is a table in the help (:help backup) that will tell you how to set these two settings.

Regards

--
--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+u...@googlegroups.com.

Christian Brabandt

unread,
Mar 8, 2026, 3:15:17 PM (22 hours ago) Mar 8
to vim...@googlegroups.com
> I tried your suggestion but I don't see any files in the .backup
> folder ?

Let me repeat:

> Please show what exactly you set

Thanks,
Christian
--
James Joyce -- an essentially private man who wished his total
indifference to public notice to be universally recognized.
-- Tom Stoppard

Christopher

unread,
Mar 8, 2026, 4:48:11 PM (20 hours ago) Mar 8
to vim_use
"set backupdir=/etc/.backup

Christopher

unread,
Mar 8, 2026, 4:49:53 PM (20 hours ago) Mar 8
to vim_use
This is what it states in the documentation

Christian Brabandt

unread,
Mar 8, 2026, 4:51:37 PM (20 hours ago) Mar 8
to vim...@googlegroups.com

On So, 08 Mär 2026, Christopher wrote:

> "set backupdir=/etc/.backup

And you have the double quote at the beginning? That is actually a
comment character. And you most likely do not want your backups to go
into /etc, unless that directory is specifically being set to allow you
to write into it. And finally, please I guess you also want :set backup
See :h backup-table


Thanks,
Christian
--
All my friends and I are crazy. That's the only thing that keeps us sane.

Christopher

unread,
Mar 8, 2026, 5:27:09 PM (19 hours ago) Mar 8
to vim_use
Putting it in quotes, causes vim to fire an error; although nothing is being written ?

Lang Hurst

unread,
Mar 8, 2026, 10:41:22 PM (14 hours ago) Mar 8
to vim...@googlegroups.com
Are you getting backup in your /home/you/vim/backup by default?
Could you attach your .vimrc?
> --
> --
> You received this message from the "vim_use" maillist.
> Do not top-post! Type your reply below the text you are replying to.
> For more information, visit http://www.vim.org/maillist.php
>
> ---
> You received this message because you are subscribed to the Google Groups "vim_use" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+u...@googlegroups.com.
> To view this discussion visit https://groups.google.com/d/msgid/vim_use/1c807e21-c69b-4b97-bd19-c7f73462a06fn%40googlegroups.com.


--
When stupidity is considered patriotism, it is unsafe to be intelligent.

-Isaac Asimov

Riza Dindir

unread,
Mar 8, 2026, 11:16:50 PM (14 hours ago) Mar 8
to vim...@googlegroups.com

"After the file has been successfully written and when the 'writebackup' option is on and the 'backup' option is off, the backup file is deleted. "

This is the default setting (as indicated in the backup help page). So you might not see the backup file.

Also as Christian Brabandt wrote, you can not have double quotes around (or at the beginning) of an option/settings statement (set backupdir=/etc/.backup), otherwise this will be treated as a commented out line.

Please share the error messages you get, and your .vimrc file that you are using.

Regards

Christian Brabandt

unread,
3:04 AM (10 hours ago) 3:04 AM
to vim...@googlegroups.com

On So, 08 Mär 2026, Christopher wrote:

> Putting it in quotes, causes vim to fire an error; although nothing is being written ?

... and the error is what? You may want to share what exactly you put
into your .vimrc.

Also please let me remind you of the list etiquette:

> Do not top-post! Type your reply below the text you are replying to.

Thanks,
Chris
--
Substantial penalty for early withdrawal.

Christian Brabandt

unread,
7:50 AM (5 hours ago) 7:50 AM
to CrestChristopher, vim...@googlegroups.com
Please keep the reply on the vim-use list, forwarding to vim-use for
reference.

On Mo, 09 Mär 2026, CrestChristopher wrote:

> Vim returns no error;
>
> set backupdir="$HOME/.backup" I've also tried
>
> set backupdir="/etc/.backup

This basically is the same as

:set backupdir=

e.g. because of the double quote acting as a comment character, you are
effectively emptying the option value.

You probably want:

:set backupdir=~/.backup//

note the trailing double slashes to ensure that backup files are written
with full path names, where slashes are replaced by % signs, as
documented at :h 'backupdir'. Please also note: I am not hundert percent
sure if Vim expands the "~" automatically, but I believe it does. If
not, you may want to explicitly spell out your home directory like this:

:set backupdir=/home/user/.backup//

Finally please note, you can always check the value by querying the
option setting directly:

:set backupdir?

> set writebackup

This will create a backup, but will delete the backup file after a
successful write. Is that what you want? Or do you want to keep the
backups in which case you want

:set backup

Thanks,
Christian
--
Wenn es etwas ist, das "jeder weiß", dann stimmt es garantiert nicht.
-- Robert Anson Heinlein (Die Leben des Lazarus Long)

CrestChristopher

unread,
7:59 AM (5 hours ago) 7:59 AM
to vim...@googlegroups.com

Although I typed out the full home path where the .backup directory is located query the path returned; backupdir=~/.backup//

In this case, after typing something in vim, and quitting without saving; there was no backup saved in the backupdir path ?

Christian Brabandt

unread,
8:24 AM (4 hours ago) 8:24 AM
to vim...@googlegroups.com
I believe backup is only ever done when saving a file, not from
arbitrary points in time. There are however plugins available that do
this. Perhaps you should start explain, what exactly you are trying to
achieve?

Thanks,
Christian
--
Just don't create a file called -rf. :-)
-- Larry Wall in <11...@jpl-devvax.JPL.NASA.GOV>

jr

unread,
8:36 AM (4 hours ago) 8:36 AM
to vim...@googlegroups.com
hi,

On Mon, 9 Mar 2026 at 11:59, CrestChristopher
<crestchr...@gmail.com> wrote:
> ...
> Although I typed out the full home path where the .backup directory is located query the path returned; backupdir=~/.backup//
> In this case, after typing something in vim, and quitting without saving; there was no backup saved in the backupdir path ?

fwiw, the line in my '~/.vimrc' reads:
set backupdir=/tmp,~/tmp

no trailing slashes, works for me.

CrestChristopher

unread,
8:38 AM (4 hours ago) 8:38 AM
to vim...@googlegroups.com
On 3/9/2026 8:22 AM, Christian Brabandt wrote:

> On Mo, 09 Mär 2026, CrestChristopher wrote:
>
>> Although I typed out the full home path where the .backup directory is
>> located query the path returned; backupdir=~/.backup//
>>
>> In this case, after typing something in vim, and quitting without
>> saving; there was no backup saved in the backupdir path ?
> I believe backup is only ever done when saving a file, not from
> arbitrary points in time. There are however plugins available that do
> this. Perhaps you should start explain, what exactly you are trying to
> achieve?
>
> Thanks,
> Christian

When I create a file in Vim, save it; a backup should be created after
the save or after I've saved and added more to the document. In either
case none of these two are working ?

Christian Brabandt

unread,
9:59 AM (3 hours ago) 9:59 AM
to vim...@googlegroups.com
So I tried this out:

#v+
~/tmp/$ mkdir ~/vim-backup
~/tmp/$ cat backup.vim
set nocp
set backupdir=~/vim-backup//
set backup
~/tmp/$ vim --clean -u backup.vim
:e ~/.vim/vimrc
:w
:q
~/tmp/$ ls -l ~/vim-backup/
-rw-r--r-- 1 chrisbra chrisbra 12481 Jan 20 2025 %home%chrisbra%.vim%vimrc~
#v-

Works as expected.


Thanks,
Christian
--
Death is God's way of telling you not to be such a wise guy.
Reply all
Reply to author
Forward
0 new messages