{"id":20419318,"url":"https://github.com/llucax/bacap","last_synced_at":"2026-04-19T01:32:13.452Z","repository":{"id":142075065,"uuid":"410241725","full_name":"llucax/bacap","owner":"llucax","description":"An extremely simple - yet configurable - backup script","archived":false,"fork":false,"pushed_at":"2024-11-10T09:58:48.000Z","size":21,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-01-15T14:16:59.240Z","etag":null,"topics":["backup","bash","rsync","rsync-backup","script"],"latest_commit_sha":null,"homepage":"https://llucax.com/proj/bacap/","language":"Shell","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/llucax.png","metadata":{"files":{"readme":"README","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2021-09-25T10:24:42.000Z","updated_at":"2025-01-04T17:30:06.000Z","dependencies_parsed_at":"2024-11-10T10:37:25.269Z","dependency_job_id":null,"html_url":"https://github.com/llucax/bacap","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/llucax%2Fbacap","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/llucax%2Fbacap/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/llucax%2Fbacap/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/llucax%2Fbacap/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/llucax","download_url":"https://codeload.github.com/llucax/bacap/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":241961220,"owners_count":20049424,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["backup","bash","rsync","rsync-backup","script"],"created_at":"2024-11-15T06:36:37.122Z","updated_at":"2026-04-19T01:32:08.402Z","avatar_url":"https://github.com/llucax.png","language":"Shell","funding_links":[],"categories":[],"sub_categories":[],"readme":".. -*- restructuredtext -*-\n\n\n==========================================\nBacap - The extremely simple backup script\n==========================================\n\n:Author: Leandro Lucarella\n:Contact: luca@llucax.com\n:Copyright: Leandro Lucarella (2010), released under the BOLA_ license\n\n.. _BOLA: http://blitiri.com.ar/p/bola/\n\n\n\nAbout\n=====\n\nBacap_ is a very simple script (~100 SLOC_ of Bash_) to do an incremental backup\nthat saves space using rsync_ and hard-links. Is not the first, and it probably\nwill not be the last, so why should you use precisely this one? I have **no**\nidea. All I can tell you is:\n\n1. I did it, so it has to be great!\n2. Is very simple, meaning is very easy to understand and customize.\n3. You can backup multiple hosts.\n\nDid I mention is very simple? I guess that is the only selling point, so\nremember: **It's very simple** =)\n\n.. _Bacap: https://github.com/llucax/bacap/\n.. _SLOC: http://en.wikipedia.org/wiki/Source_lines_of_code\n.. _Bash: http://www.gnu.org/software/bash/\n.. _rsync: http://rsync.samba.org/\n\n\n\nInstallation\n============\n\nDoing something very complex in ~100 SLOC_ is not easy, unless you're standing\nin the shoulders of giants. I'm standing in the shoulders of rsync_ mainly, so\nyou should install it before using the script. You will need a bunch of `basic\nPOSIX commands`__, like ``date``, ``dirname``, ``readlink``, ``basename``,\n``cat``, ``awk``, etc.; and ``crontab`` if you don't want to run the script\nmanually each time you remember to actually do a backup; but I'm sure you\nalready have those.  And of course, Bash_, but again, I'm sure you have it too.\nIf you want to backup remote hosts, be sure ssh_ is installed too.\n\n__ http://www.opengroup.org/onlinepubs/009695399/utilities/toc.html\n.. _ssh: http://www.openssh.com/\n\nOnce you have it all, just `download the script`__ from the git_ repo__ and copy\nit to wherever you like. Set the executable bit if appropriate::\n\n\tchmod a+x bacap\n\n__ https://raw.githubusercontent.com/llucax/bacap/main/bacap\n__ https://github.com/llucax/bacap\n.. _git: http://git-scm.com/\n\n\n\nConfiguration\n=============\n\nIf you don't like the defaults (you probably wont), you can add a configuration\nfile. Configuration files are searched in this places:\n\n1. ``/etc/bacaprc``\n2. ``/etc/bacap/bacaprc``\n3. ``bacaprc`` in the same directory as the ``bacap`` script\n4. Optional parameter passed as argument to the script\n5. ``$CONFIG_PATH/$HOST/bacaprc``\n\nOrder is important, since all files are read (if possible) and values in the\nlast configuration file read overwrites old values. The script takes an optional\nparameter, which is another location to look for a configuration file. If the\nconfiguration file passed as argument can't be found, an error will be printed\n(no error is issued if any of the other configuration files are missing).\nAlso, config options could be specified on a per host basis by creating a\n``bacaprc`` file in ``$CONFIG_PATH/$HOST``. As a side effect of this,\nconfiguration file(s) are read initially and each time the script backups a new\nhost. So the configuration file(s) are read at least two times even if you\nbackup one host.\n\nThe configuration file is a Bash_ script too, you can see the `default values\nin the script`__.\n\n__ https://github.com/llucax/bacap/blob/main/bacap#L4-L44\n\nOnce you've created the configuration file(s), you should create the directory\n``$CONFIG_PATH`` (meaning, the value you used for that variable in the\nconfiguration file)::\n\n\tmkdir -p $CONFIG_PATH\n\nThen create a directory for each host you want to backup there, the directory\nname should be the name of the host (as you would use to connect to it using\nssh_). For now let's say we will only backup ``localhost``::\n\n\tmkdir $CONFIG_PATH/$LOCALHOST\n\nYou should be able to guess what ``$LOCALHOST`` stands for by now =)\n\nNow, you should create at least one file there, ``paths`` which should have one\nline for each path to backup in that host. Let's say we want to backup only\n``/etc`` and ``/home``::\n\n\techo /etc \u003e $CONFIG_PATH/$LOCALHOST/paths\n\techo /home \u003e\u003e $CONFIG_PATH/$LOCALHOST/paths\n\nBut sometimes there are things there that you don't want to backup, in that\ncase you can create a file named ``excludes`` too, and write which paths you\nwant to exclude there, one path in each line (you can use wildcards and anything\nsupported by the ``--exclude-from`` rsync_ option). Let's say we don't want to\nbackup rata's home::\n\n\techo /home/rata/ \u003e $CONFIG_PATH/$LOCALHOST/excludes\n\nAlso, if you don't want to exclude files matching some pattern, you can create\na file named ``includes`` with the patterns you want to include (you can use\nanything supported by the ``--include-from`` rsync_ option)\n\nThat's pretty much it. If you want to add other hosts, just create the host\ndirectory and the needed host configuration files.\n\n\n\nUsage\n=====\n\nAs we said in the configuration section, the only argument the script take is an\nextra configuration file. All options are managed through configurations files.\n\nThe script creates a new directory in ``$BACKUP_PATH/$host/$date`` and copies\n(hard-links) the configured paths for each ``$host``. ``$date`` is the current\ndate at the time of starting the script, formatted according to ``$DATE_FMT``. By\ndefault this has day *resolution*, but you can add hours, minutes or even\nseconds if you want to do more frequent backups. If the directory already exist\nfor any host, it skips that host.\n\nA symbolic link is created at the end of the backup, with the name\n``$BACKUP_PATH/$host/current``, and pointing to the newly created directory.\n\n\n\nTips\n====\n\nHere are a few tips on how to configure Bacap_ for several common scenarios.\n\nAutomating backups using cron\n-----------------------------\n\nYou probably want to automate your backup using *cron*. I will not include\na *cron* tutorial here, but if you are completely lost, you can add this line to\n``/etc/crontab`` to make a daily backup at 6:30::\n\n\t30 6 * * * root /path/to/bacap\n\nIf you are a Debian_ user, you can also simply install the script in\n``/etc/cron.daily`` (or make a symlink or something similar) and you are set.\n\n.. _Debian: http://www.debian.org/\n\n\nProviding a ssh_ key\n--------------------\n\nWhen doing a backup of a remote host, you probably want ssh_ to be able to\nlogin without providing a password. To do so, you can generate a ssh_ key using\n``ssh-keygen``, copy the public key to the target's\n``/root/.ssh/authorized_keys`` using ``ssh-copy-id root@host`` (or the user\nthat runs the backup) and set the Bacap_ configuration variable ``RSYNC_RSH``\nto something like::\n\n\tRSYNC_RSH=\"ssh -i /path/to/priv-key -o NumberOfPasswordPrompts=0\"\n\nThe ``-o NumberOfPasswordPrompts=0`` is not necessary, but you would appreciate\nit if something is wrong with your key, since if you don't use it, rsync_ will\nhang asking for a password.\n\nAlso, you may consider using ``StrictHostKeyChecking=no`` ssh option if you\nbackup hosts with dynamic IP address.\n\n\nBackup local networks nodes (or nodes with a fast connection)\n-------------------------------------------------------------\n\nWhen the bandwidth is not tight, you probably want to ensure ssh_ doesn't use\ncompression::\n\n\tRSYNC_RSH=\"ssh -o Compression=no\"\n\nAnd if your network is trusted, you probably don't need very strong encryption\neither::\n\n\tRSYNC_RSH=\"ssh -o Compression=no -c arcfour\"\n\n\nListing differences between 2 snapshots\n---------------------------------------\n\nIf you want to see what have actually changed between two backups you can run\nrsync_ with your usual flags plus ``-nv --delete``. For example if you just use\n``-a``, to see the differences between ``lolaus/2010-07-11`` and\n``lolaus/2010-07-12`` you can run::\n\n        rsync -nav --delete lolaus/2010-07-11/ lolaus/2010-07-12/\n\n\n\nSimilar alternatives\n====================\n\n* Do it yourself: this script was **heavily** inspired by an article__ by `Kevin\n  Korb`__ (well, it was really inspired by the `previous version`__ of the\n  article =).\n* `Back In Time`__: Nice looking graphical alternative.\n* `rsnapshot`__: A more mature and heavier alternative. I didn't really used it\n  though, so I can't say much.\n\n__ http://www.sanitarium.net/golug/rsync_backups_2010.html\n__ http://www.sanitarium.net/\n__ http://www.sanitarium.net/golug/rsync_backups_2005.html\n\n__ http://backintime.le-web.org/\n\n__ http://rsnapshot.org/\n\n\nI'm sure there are plenty of others, if you have one and want to be listed here,\nplease feel free to `drop me an e-mail`__.\n\n__ mailto:luca@llucax.com\n\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fllucax%2Fbacap","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fllucax%2Fbacap","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fllucax%2Fbacap/lists"}