Linode Backup Failure: Too Many Files

Linode Staff

After a recent Backup Failure ticket, I was told that my Linode has too many files on it. It looks like it’s mostly session and tmp files. What’s a good way to deal with these files moving forward to both get my backups running again and so I don’t have to worry about this again?

1 Reply

Because our Backup service is file-based, the overall number of files on the Linode will affect both the time needed for a backup to run, but also the time needed for any restore jobs. This is one of the limtations for our service. There isn’t a magic number to avoid, as this limitation can be triggered by large number of small files, or a specific directory with a large number of files.

If you wish to get your backups …back up and running, you have two options:

  • Get rid of those files
  • Keep those files

Both of these options can be handled automatically by your Linode.

Removing Files

For removing files, a simple cron job with the correct scheduling, can remove any unnecessary files. Below I’ll provide some tips on setting up a cron to remove files from a directory, though if you’d like a deeper dive into cron, check out our guide: Schedule Tasks with Cron

Cron is a scheduling daemon that will watch the clock and run a command that you tell it to when you tell it to run. These are managed through crontab, or cron tables. Using crontab, you can set a schedule and a script or command for it to run at that time.

First, you’ll want to identify which directories need to be addressed. To find directories with a lot of files:

sudo find / -type f | perl -aF/ -lne 'for (my $i=0; $i < @F-1; ++$i) { print join("/",@F[0...$i]); }' | sort | uniq -c | sort -n | tail -30

Once you know the absolute path that you’re looking to keep the file count down in, you’re ready to set up the cron job. Start by bringing up the crontab editor. The text editor it uses (nano, vi, etc), will be based on your Linode’s settings:

crontab -e

Next, at the end of the file, under all the commented out lines, you’ll add the command for removing the files. A sample entry could look like this:

0 0 * * 0 rm -rf /path/to/directory/you/wish/to/delete/*

This will run the rm command for all files in the directory every Sunday.

Important note: without appending the asterisk at the end, it will attempt to remove the directory, which could disrupt services that are looking to write to a specific directory.

Possible options for frequency:

0 0 1 * * rm -rf /directory/path/to/delete/*

0 0 * * 0 rm -rf /directory/path/to/delete/*

If you want to schedule this cron job for a different time, cron scheduling can be a little confusing. I used this site to help me with getting the right syntax:

Keep the files

If the files are important and can’t be removed, you have the option of archiving them into a compressed file to reduce overall file count. Using the [logrotate:] can enable you to automatically compress the files in a directory to keep the files size getting to a point where it hits the limitation.

In the logrotate.conf file, you’ll want to uncomment out the line that reads compress. By default, it’s commented out, so it won’t compress the files.

Then, you’ll want to add the directories, which will look something like this:

/path/to/the/directory {
    create 0664 root utmp
    rotate 1

I took that example from the default logrotate.conf file, but changed the path for my example. The doc on logrotate that I linked above goes into greater detail on what each of those parameters are, how they behave, and other ones your might want to include, such as emailing yourself the logs to store off the Linode.

If you’re just looking to do a one-time archive, we have great documentation on how to do that as well:


Please enter an answer

You can mention users to notify them: @username

You can use Markdown to format your question. For more examples see the Markdown Cheatsheet.

> I’m a blockquote.

I’m a blockquote.

[I'm a link] (

I'm a link

**I am bold** I am bold

*I am italicized* I am italicized

Community Code of Conduct