* deleting backup files dependant on their age
@ 2015-11-23 19:46 Sharon Kimble
2015-11-23 20:14 ` Eli Zaretskii
` (3 more replies)
0 siblings, 4 replies; 6+ messages in thread
From: Sharon Kimble @ 2015-11-23 19:46 UTC (permalink / raw)
To: help-emacs
[-- Attachment #1: Type: text/plain, Size: 2134 bytes --]
I'm revisiting the age-old problem of deleting backup files, where
currently I have 1,383 which is increasing day-by-day. I have this in my
init.org -
--8<---------------cut here---------------start------------->8---
(setq backup-directory-alist '(("." . "~/.emacs.d/backups/"))
backup-by-copying t
version-control t
delete-old-versions t
kept-new-versions 2
kept-old-versions 1)
--8<---------------cut here---------------end--------------->8---
but it doesn't seem to be deleting the old files.
So I've googled and found this on
http://www.emacswiki.org/emacs/BackupDirectory
--8<---------------cut here---------------start------------->8---
(message "Deleting old backup files...")
(let ((week (* 60 60 24 7))
(current (float-time (current-time))))
(dolist (file (directory-files temporary-file-directory t))
(when (and (backup-file-name-p file)
(> (- current (float-time (fifth (file-attributes file))))
week))
(message "%s" file)
(delete-file file))))
--8<---------------cut here---------------end--------------->8---
which I've amended to only work on files older than 14 days
--8<---------------cut here---------------start------------->8---
#+begin_src emacs-lisp
(message "Deleting old backup files...")
(let ((fortnight (* 60 60 24 14))
(current (float-time (current-time))))
(dolist (file (directory-files ~/.emacs.d/backups t))
(when (and (backup-file-name-p file)
(> (- current (float-time (fifth (file-attributes file))))
fortnight))
(message "%s" file)
(delete-file file))))
#+end_src
--8<---------------cut here---------------end--------------->8---
but its failing to work, saying this -
╭────
│Symbol's value as variable is void: ~/.emacs.d/backups
╰────
How then can I set up auto-delete backup files for older than 14 days
which are held in "~/.emacs.d/backups" please?
Thanks
Sharon.
--
A taste of linux = http://www.sharons.org.uk
TGmeds = http://www.tgmeds.org.uk
Debian 8.0, fluxbox 1.3.7, emacs 24.5.1
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 818 bytes --]
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: deleting backup files dependant on their age
2015-11-23 19:46 deleting backup files dependant on their age Sharon Kimble
@ 2015-11-23 20:14 ` Eli Zaretskii
2015-11-24 0:01 ` Emanuel Berg
` (2 subsequent siblings)
3 siblings, 0 replies; 6+ messages in thread
From: Eli Zaretskii @ 2015-11-23 20:14 UTC (permalink / raw)
To: help-gnu-emacs
> From: Sharon Kimble <boudiccas@skimble.plus.com>
> Date: Mon, 23 Nov 2015 19:46:31 +0000
>
> I'm revisiting the age-old problem of deleting backup files, where
> currently I have 1,383 which is increasing day-by-day. I have this in my
> init.org -
>
> --8<---------------cut here---------------start------------->8---
> (setq backup-directory-alist '(("." . "~/.emacs.d/backups/"))
> backup-by-copying t
> version-control t
> delete-old-versions t
> kept-new-versions 2
> kept-old-versions 1)
> --8<---------------cut here---------------end--------------->8---
>
> but it doesn't seem to be deleting the old files.
Please show an example of "doesn't seem to be deleting old files". It
is not clear from this description what you expected this to do and
what you actually observe.
> --8<---------------cut here---------------start------------->8---
> #+begin_src emacs-lisp
> (message "Deleting old backup files...")
> (let ((fortnight (* 60 60 24 14))
> (current (float-time (current-time))))
> (dolist (file (directory-files ~/.emacs.d/backups t))
> (when (and (backup-file-name-p file)
> (> (- current (float-time (fifth (file-attributes file))))
> fortnight))
> (message "%s" file)
> (delete-file file))))
> #+end_src
> --8<---------------cut here---------------end--------------->8---
>
> but its failing to work, saying this -
>
> ╭────
> │Symbol's value as variable is void: ~/.emacs.d/backups
> ╰────
It should be a string, in quotes.
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: deleting backup files dependant on their age
2015-11-23 19:46 deleting backup files dependant on their age Sharon Kimble
2015-11-23 20:14 ` Eli Zaretskii
@ 2015-11-24 0:01 ` Emanuel Berg
2015-11-24 0:58 ` Emanuel Berg
[not found] ` <mailman.585.1448326084.31583.help-gnu-emacs@gnu.org>
3 siblings, 0 replies; 6+ messages in thread
From: Emanuel Berg @ 2015-11-24 0:01 UTC (permalink / raw)
To: help-gnu-emacs
Sharon Kimble <boudiccas@skimble.plus.com> writes:
> I'm revisiting the age-old problem of deleting
> backup files, where currently I have 1,383 which is
> increasing day-by-day.
OK, first, by "backups", you mean files like
this~, right?
Second, are you sure 1383 files is a problem? As an
example, I have 887 mails (not backups) in a folder
and according to
du -sh
they total 89M. So it is not a lot.
Third, you can use the -I option of ls(1) if you just
don't want to see them.
Fourth, if you would consider no backups at all, try
this:
(setq make-backup-files nil)
(setq auto-save-list-file-prefix nil)
> I have this in my ... but its failing to work, saying this -
> Symbol's value as variable is void:
> ~/.emacs.d/backups
You probably need to make that a string, i.e.
"~/.emacs.d/backups".
> How then can I set up auto-delete backup files for
> older than 14 days which are held in
> "~/.emacs.d/backups" please?
You can also do this in the shell with find(1) but
perhaps you want do try the Emacs solution first.
Otherwise it would probably be just as doable
with 'find'.
--
underground experts united
http://user.it.uu.se/~embe8573
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: deleting backup files dependant on their age
2015-11-23 19:46 deleting backup files dependant on their age Sharon Kimble
2015-11-23 20:14 ` Eli Zaretskii
2015-11-24 0:01 ` Emanuel Berg
@ 2015-11-24 0:58 ` Emanuel Berg
[not found] ` <mailman.585.1448326084.31583.help-gnu-emacs@gnu.org>
3 siblings, 0 replies; 6+ messages in thread
From: Emanuel Berg @ 2015-11-24 0:58 UTC (permalink / raw)
To: help-gnu-emacs
If you want to try find(1), I "found" this site [1],
and if I modified it correctly for your purposes it
should be:
find ~/.emacs.d/backups/.*~ -mtime +14 -exec rm {} \;
Be careful with this command! Don't blame me if you
wipe your disk. (Or you can blame me, but that won't
get your files back.)
[1] http://www.howtogeek.com/howto/ubuntu/delete-files-older-than-x-days-on-linux/
--
underground experts united
http://user.it.uu.se/~embe8573
^ permalink raw reply [flat|nested] 6+ messages in thread
[parent not found: <mailman.585.1448326084.31583.help-gnu-emacs@gnu.org>]
* Re: deleting backup files dependant on their age
[not found] ` <mailman.585.1448326084.31583.help-gnu-emacs@gnu.org>
@ 2015-11-24 4:46 ` Dan Espen
2015-11-25 1:26 ` Emanuel Berg
0 siblings, 1 reply; 6+ messages in thread
From: Dan Espen @ 2015-11-24 4:46 UTC (permalink / raw)
To: help-gnu-emacs
Emanuel Berg <embe8573@student.uu.se> writes:
> If you want to try find(1), I "found" this site [1],
> and if I modified it correctly for your purposes it
> should be:
>
> find ~/.emacs.d/backups/.*~ -mtime +14 -exec rm {} \;
>
> Be careful with this command! Don't blame me if you
> wipe your disk. (Or you can blame me, but that won't
> get your files back.)
>
> [1] http://www.howtogeek.com/howto/ubuntu/delete-files-older-than-x-days-on-linux/
That doesn't work for me.
Try this:
find ~/.emacs.d/backups -name '*~' -mtime +14 -exec rm {} \;
--
Dan Espen
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: deleting backup files dependant on their age
2015-11-24 4:46 ` Dan Espen
@ 2015-11-25 1:26 ` Emanuel Berg
0 siblings, 0 replies; 6+ messages in thread
From: Emanuel Berg @ 2015-11-25 1:26 UTC (permalink / raw)
To: help-gnu-emacs
Dan Espen <despen@verizon.net> writes:
>> If you want to try find(1), I "found" this site,
>> and if I modified it correctly for your purposes it
>> should be: find ~/.emacs.d/backups/.*~ -mtime +14
>> -exec rm {} \;
>
> That doesn't work for me.
>
> Try this:
>
> find ~/.emacs.d/backups -name '*~' -mtime +14 -exec rm
> {} \;
Indeed, it doesn't work for me either :)
To the OP, you can either put that in a shell function
(in .bashrc or .zshrc etc.) and then invoke it once in
a while, or you can semi-automatize it by putting it
in a startup file, e.g. .xinitrc if you use
X (likely). If so, use the actual command, not the
shell function as that might be invisible from
.xinitrc - actually, I don't remember, but 'find' is
available, for sure, as it is a binary: /usr/bin/find.
(You might still want the shell function as that
facilitates getting the command to work.)
There are more refined ways to automatize things but
it is overkill in this case I would say.
Actually removing the backups all all is "a little"
overkill :)
--
underground experts united
http://user.it.uu.se/~embe8573
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2015-11-25 1:26 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-11-23 19:46 deleting backup files dependant on their age Sharon Kimble
2015-11-23 20:14 ` Eli Zaretskii
2015-11-24 0:01 ` Emanuel Berg
2015-11-24 0:58 ` Emanuel Berg
[not found] ` <mailman.585.1448326084.31583.help-gnu-emacs@gnu.org>
2015-11-24 4:46 ` Dan Espen
2015-11-25 1:26 ` Emanuel Berg
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).