You are not logged in.

#1 2010-03-22 15:44:17

Giselher
Member
From: Austria
Registered: 2010-02-02
Posts: 150
Website

apbp - A simple backup script

I have written a little backup script that I can use with cron to save my data.  It adds all files with absolute path names in an archive. The archive can be either gzip or bzip2 compressed.

It depends on python and there is time and date support for the name of the archive.

Some examples:

alexander:~$ apbp -v -x workplace.tar.gz -i workplace/archhurd,workplace/haskell workplace

You can also create a backup file:

alexander:~/backup_scripts$ cat schule 
#!/usr/bin/apbp -c 
archive=/home/backups/schule_%Y-%m-%d_%H:%M.tar.gz
files=/home/alexander/Schule
ignore=/home/alexander/Schule/vbshare,/home/alexander/Schule/DrupalMachine.vdi
replace
alexander:~/backup_scripts$ apbp -c schule

If you add replace in your backup file, the previous archive file will be replaced by the new archive.


Because of the shebang you could also use it as script.

alexander:~/backup_scripts$ chmod +x schule 
alexander:~/backup_scripts$ ./schule

If you lost data like I did (rm -fr * FTW) you can also restore the data.

alexander:~$ apbp -r /home/backups/workplace.tar.bz2

Do NOT restore old archives! It will overwrite your original files.

Here is my crontab:

0 9 * * *   $HOME/backup_scripts/savegames
0 9 * * fri $HOME/backup_scripts/schule
0 9 * * mon $HOME/backup_scripts/workplace

I hope you like it smile .

The script is available on the aur.
AUR: http://aur.archlinux.org/packages.php?ID=35834

Last edited by Giselher (2010-03-22 16:31:43)

Offline

#2 2010-03-22 15:51:38

Ramses de Norre
Member
From: Leuven - Belgium
Registered: 2007-03-27
Posts: 1,289

Re: apbp - A simple backup script

Seems very nice! I'll give it a try when I find the time to do so smile

Offline

#3 2010-03-22 18:21:57

Giselher
Member
From: Austria
Registered: 2010-02-02
Posts: 150
Website

Re: apbp - A simple backup script

I have added two new features.

* partial restore

apbp -r some.tar.gz /home/test/lostmydata

This will only restore the file (or files in this directory) you give.
I added this feature because nobody will really restore everything form the backup archive.

*  different separator

apbp -s : -i /home:/etc:/dev /
#!/usr/bin/apbp - c
name= ...
separator=SEP
files=/homeSEP/etcSEP/root
#!/usr/bin/apbp -s '||' - c
name= ...
files=/home||/etc||/root

I added this feature because sometimes there are commas in pathnames


I will update the aur packages as soon as possible
EDIT: AUR packages is now up to date

Last edited by Giselher (2010-03-22 18:29:55)

Offline

#4 2010-03-24 10:49:37

Giselher
Member
From: Austria
Registered: 2010-02-02
Posts: 150
Website

Re: apbp - A simple backup script

With apbp 1.2 its possible to enter how many files will be kept before the oldest will be replaced .

#!/usr/bin/apbp -c 
name=...
...
replace=3

The script will keep 3 files and will remove the oldest if a new archive is created.

replace=0 Will keep all files.
replace == replace=1

Last edited by Giselher (2010-03-24 11:00:42)

Offline

Board footer

Powered by FluxBB