Backing up using snap2

Run snap2 (the GUI) to set up and optionally run your backups.  If running a Debian-based distribution, Look for the snap2 menu entries in the KDE menu, under "Utilities," or in the Debian menu, under "Applications/File Management.

In Puppy Linux, the menu entries will be in 'Utility.'

As indicated by the snap2 program, there are basically 3 steps to setting up your backups:

  1. On the 'DIRECTORIES TO BACK UP' main tab, click either the snapshot or the mirror source directories sub-tab, depending on what sort of backup you want. To help you decide which kind of backup to do, see this page. Add directories to backup by clicking the folder icon to the right of the input area below 'New Top-Level Source Directory'. Once you have selected a directory, click the 'Add as...' button to the right.
  2. Add any backup "exclusion" patterns for the directory you wish to back up.  When a file or directory matches an exclusion pattern, it is skipped (not backed up). Help on exclusion patterns.
  3. On the BACKUP STORAGE tab, set the storage directory for your backups.  This can be a remote server.  If it is a remote server and ssh public key authentication is not yet set up, go to the ADVANCED SETTINGS tab and click the 'Remote Authentication' button.

That's really all there is to it!  You are ready to click one of the '...Backup Now' buttons to do your backup.  There are a number of settings you can modify on the ADVANCED SETTINGS page, but the program's defaults are good for most people.

Non-interactive Use

After running snap2 and configuring your backups, snap2 can also be run non-interactively (one-click execution). Look for "snap2 snapshot backup" in the KDE or Debian menus.  This menu entry runs the current user's snapshot backup, using the default backup directory settings. (You can create a similar menu entry to run mirror-type backups). In Puppy Linux, the menu entries are in the "Utility" menu.

If you would like to create an icon to execute snap2 for mirror-type backups, or for a different settings directory, the syntax is:

snap2shell <snapshot | mirror> [settingsdirectory]

snap2shell runs the backup non-interactively, but pauses at the end so you can see any error messages.

The optional settingsdirectory argument specifies an alternate settings directory.  Alternate settings directories are created and configured in snap2 (the interactive GUI).  An alternate settings directory would allow you to, for example, run snapshot-type backups to 2 different destinations.  Specifically, you might do snapshot backups for some source directories to a local USB flash drive, and for other source directories to a remote server.  More information here.

Execution via cron

Snap2 can set up cron tasks for you, for automatically-recurring backups.  Look on the ADVANCED SETTINGS tab for the 'Automatic Backup Scheduler' button. In my opinion this is usually the best way to run snap2.

If you decide to make your cron entry manually, you would invoke snap2engine rather than snap2shell (snap2shell pauses after the backup is done, which for a cron job is definitely not wanted).

A typical cron entry to run snap2 would look like this (in /etc/crontab):

59 8 * * * /usr/local/bin/snap2-engine snapshot lloyd

The syntax for snap2engine is:

snap2engine <snapshot | mirror> [settingsdirectory] [user]

As the above notation indicates, the optional settingsdirectory argument is used to specify an alternate settings directory.  If not provided, the default is 'default.set'.  The user argument is used to specify the username.  This must be the same user who is executing the backup.  Note that although this is an optional argument to snap2engine, it is necessary when snap2engine is excuted by a cron task

An Example Backup

One of my my top level snapshot backup directory is  /home/lloyd. - my home directory. I use the following list of exclusion patterns (explained in detail here):

- cache/
- /home/lloyd/nobackup
- /home/lloyd/.ICEauthority
- /home/lloyd/.Xauthority
- /home/lloyd/.AbiSuite
- /home/lloyd/.opera
- /home/lloyd/.Trash
- /home/lloyd/.xsession-errors
- /home/lloyd/.mc
- /home/lloyd/.dvdcss
- /home/lloyd/.openoffice*
- /home/lloyd/tmp
- /home/lloyd/mail
- /home/lloyd/.bash_history
- /home/lloyd/.lesshst
- /home/lloyd/google-earth
- /home/lloyd/.kpackage
- /home/lloyd/.local/share/Trash
- /home/lloyd/.mozilla/**/Cache
- /home/lloyd/.thumbnails
- /home/lloyd/.Skype

Note that since I have 'Add Default Exclusions' checked on the ADVANCED SETTINGS page, these exclusions patterns are used in addition to the default exclusions.

The default exclusions patterns can be edited by a button on the ADVANCED SETTINGS page.  snap2 ships with the following default exclusion patterns:

- *~
- *.log
- temp/
- tmp

This means snap2 will not back up any file ending in '~' or '.log', nor any directory named temp, nor any file or directory named 'tmp'.

The first time the snapshot backup is run, the backup starts at my top level backup directory /home/lloyd, and all files are backed up EXCEPT those matching the above file exclusion patterns.  This backup, including full directory structure, is in a directory named 'recent.1'

The next time snap2 is run, only new and modified files are stored, although the backup appears to be a complete new copy.  The most recent backup directory (usually recent.1) is always used as the 'hard link reference' for a new snapshot backup.

"recent" snapshots are created in directories named recent.1 to recent.n, where 'n' is the configurable limit of recent snapshots.  The last recent backup is always in 'recent.1'.  The previous newest backup has its name changed to 'recent.2', and what was recent.2 becomes recent.3, etc.  The oldest 'recent' backup (recent.8 if n=8), is either 'promoted' to be a 'daily' backup, or discarded, depending on its age.  If it is at least 24 hours newer than the latest 'daily' snapshot, it is promoted to daily.1 (the newest 'daily' backup), which in turn rotates the 'daily' snapshot stack.  Otherwise it is discarded.

"daily" snapshots are handled similarly: daily.1 to daily.n, where 'n' equals the daily snapshot.  When the oldest daily snapshot would be rotated-off the daily stack, and it is at least one week newer than newest 'weekly' snapshot, it is 'promoted' to be a weekly snapshot instead of being discarded.

"monthly" snapshots are rotated similarly.

Note that there can be more than 7 'daily' snapshots backups, and more than 4 'weekly' snapshots, etc.

Over time, the program rotates the backups to create a directory structure like this:

lloyd@debiandesk:/media/BACKUP8GIG/snapbackups$ ls -l
total 96
drwxr-xr-x 4 lloyd lloyd 4096 2009-08-23 21:12 daily.1
drwxr-xr-x 4 lloyd lloyd 4096 2009-08-22 08:35 daily.2
drwxr-xr-x 4 lloyd lloyd 4096 2009-08-21 08:35 daily.3
drwxr-xr-x 4 lloyd lloyd 4096 2009-08-18 08:35 daily.4
drwxr-xr-x 4 lloyd lloyd 4096 2009-08-17 08:35 daily.5
drwxr-xr-x 4 lloyd lloyd 4096 2009-08-16 08:35 daily.6
drwxr-xr-x 4 lloyd lloyd 4096 2009-08-14 08:35 daily.7
drwxr-xr-x 4 lloyd lloyd 4096 2009-08-13 08:35 daily.8
drwxr-xr-x 4 lloyd lloyd 4096 2009-08-12 08:35 daily.9
drwxr-xr-x 3 lloyd lloyd 4096 2009-10-07 23:06 mirror
drwxr-xr-x 4 lloyd lloyd 4096 2009-05-25 08:35 monthly.1
drwxr-xr-x 4 lloyd lloyd 4096 2009-04-19 08:35 monthly.2
drwxr-xr-x 4 lloyd lloyd 4096 2009-03-19 08:35 monthly.3
drwxr-xr-x 4 lloyd lloyd 4096 2009-02-08 22:24 monthly.4
drwxr-xr-x 4 lloyd lloyd 4096 2009-10-15 22:36 recent.1
drwxr-xr-x 4 lloyd lloyd 4096 2009-10-13 20:59 recent.2
drwxr-xr-x 4 lloyd lloyd 4096 2009-10-07 23:04 recent.3
drwxr-xr-x 4 lloyd lloyd 4096 2009-09-07 13:51 recent.5
drwxr-xr-x 4 lloyd lloyd 4096 2009-08-27 08:35 recent.6
drwxr-xr-x 4 lloyd lloyd 4096 2009-08-06 08:35 weekly.1
drwxr-xr-x 4 lloyd lloyd 4096 2009-07-30 08:35 weekly.2
drwxr-xr-x 4 lloyd lloyd 4096 2009-07-22 08:35 weekly.3
drwxr-xr-x 4 lloyd lloyd 4096 2009-07-14 18:00 weekly.4

Each of those directories, by the way, contains a full 'snapshot' backup of my entire home directory.  Some of these snapshots hold 5 gigs of files.  The total occupied space is apparently 30 gigs.

In reality, however, only about 6 gigs were actually used on this 8 gig flash memory drive!


in some installations the snapshot binaries lie in /usr/bin

in some installations the snapshot binaries lie in /usr/bin and not /usr/local/bin

Snapshot binaries?  Do you

Snapshot binaries?  Do you mean the snap2 binaries?  If you install snap2 using my Debian packages, the binaries will reside in /usr/bin.

/usr/local/bin is for user-compiled binaries.  That is, programs the user has custom-compiled after installing the operating system.  I believe this convention is respected by all Linux distros.

If you are saying that a user should usually include /usr/local/bin as a directory to back up, that is certainly true.  Thanks for your comments.

Nice but you forgot to include the code

HI! very good I searched for how to cron snapshot and found this very comprehensive article. It's a great documentation Much thanks. But however you didn't include sample of the code except for the cron. Also I'm not familiar with linux cron so an explanation of what the numbers in '59 8 * * * /usr/local/bin/snap2-engine snapshot lloyd' mean would be greatly appreciated. Thanks

Hi.  As I wrote in my

Hi.  As I wrote in my article,

"Snap2 can set up cron tasks for you, for automatically-recurring backups.  Look on the ADVANCED SETTINGS tab for the 'Automatic Backup Scheduler' button."

In other words, snap2 is also a GUI interface to cron, for running the backup. So you don't have to know the cron syntax to schedule automatic (cron-triggered) backups.

Direct invocation of "snap2engine" from the command line or via cron is advanced use, and advanced users will know how to invoke cron, or will know how to find out the syntax. (hint: google "crontab syntax", without the quotes)

Post new comment

The content of this field is kept private and will not be shown publicly.
  • Allowed HTML tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd> <p> <br> <img> <alt> <h1> <h2> <h3>
  • Lines and paragraphs break automatically.

More information about formatting options

This question is to prevent automated spam submissions.
                    _    ____    __     ____  
_ _ __ __ (_) / ___| / /_ | _ \
| | | | \ \ / / | | | | | '_ \ | | | |
| |_| | \ V / | | | |___ | (_) | | |_| |
\__,_| \_/ _/ | \____| \___/ |____/
Enter the code depicted in ASCII art style.