FAQ Search Today's Posts Mark Forums Read
» Video Reviews

» Linux Archive

Linux-archive is a website aiming to archive linux email lists and to make them easily accessible for linux users/developers.


» Sponsor

» Partners

» Sponsor

Go Back   Linux Archive > Ubuntu > Ubuntu User

 
 
LinkBack Thread Tools
 
Old 09-16-2012, 08:08 PM
"Murat D. Kadirov"
 
Default Quick backup

On 17.09.2012 01:11, Johnny Rosenberg wrote:

I wrote a backup Bash-script many years ago. It works perfectly and it
backs up selected folders to an external USB drive. Works excellent,
as I said, but everything can be just a little bit better, right?
So now I have some thoughts about this.
You are using your computer for different stuff. Now and then you save
files, no matter what software you are using. Could be LibreOffice,
Audacity, Ardour, even your web browser, maybe an email client, if you
use one, maybe the touch command in a terminal and so on. Is there
something in the system that can be read that logs everything that's
written to (or removed from) the file system? Or is there a signal
somewhere telling the system that ”this.file was written to/removed
from /path/to/the/file/in/question/ at 2012-09-16 21:02:18” or
something like that?

Sometimes a do a backup, then I open a file for editing, change some
stuff, save it, then do a new backup. Sometimes I wonder why the new
backup takes some time; I only changed one file, right?
I don't want my USB drive to be powered on all the time (it's not
quiet enough for that), so what about if I could read the system for
when and where files are saved and save that info to a text file?
Then, before shutting down, I could just run a script that reads that
file and copy only those files to their corresponding places on that
USB drive (reminding me to turn it on if I didn't – something that my
present backup script already does).

Is this possible? It should be, because UbuntuOne already does it, as
it seems. But maybe I can't do it from a Bash-script? It would mean
very quick backups anyway, since it didn't need to search the whole
USB disk for missing files or files that need to be removed.



Kind regards

Johnny Rosenberg
ジョニー・*ーゼンバーグ


https://en.wikipedia.org/wiki/Inotify

--
Murat D. Kadirov
PGP fingerprint: 3081 EBFA 5CB9 BD24 4DB6 76EE 1B97 0A0E CEC0 6AA0


--
ubuntu-users mailing list
ubuntu-users@lists.ubuntu.com
Modify settings or unsubscribe at: https://lists.ubuntu.com/mailman/listinfo/ubuntu-users
 
Old 09-16-2012, 08:49 PM
Jared Norris
 
Default Quick backup

On 17 September 2012 05:11, Johnny Rosenberg <gurus.knugum@gmail.com> wrote:
> I wrote a backup Bash-script many years ago. It works perfectly and it
> backs up selected folders to an external USB drive. Works excellent,
> as I said, but everything can be just a little bit better, right?
> So now I have some thoughts about this.
> You are using your computer for different stuff. Now and then you save
> files, no matter what software you are using. Could be LibreOffice,
> Audacity, Ardour, even your web browser, maybe an email client, if you
> use one, maybe the touch command in a terminal and so on. Is there
> something in the system that can be read that logs everything that's
> written to (or removed from) the file system? Or is there a signal
> somewhere telling the system that ”this.file was written to/removed
> from /path/to/the/file/in/question/ at 2012-09-16 21:02:18” or
> something like that?
>
> Sometimes a do a backup, then I open a file for editing, change some
> stuff, save it, then do a new backup. Sometimes I wonder why the new
> backup takes some time; I only changed one file, right?
> I don't want my USB drive to be powered on all the time (it's not
> quiet enough for that), so what about if I could read the system for
> when and where files are saved and save that info to a text file?
> Then, before shutting down, I could just run a script that reads that
> file and copy only those files to their corresponding places on that
> USB drive (reminding me to turn it on if I didn't - something that my
> present backup script already does).
>
> Is this possible? It should be, because UbuntuOne already does it, as
> it seems. But maybe I can't do it from a Bash-script? It would mean
> very quick backups anyway, since it didn't need to search the whole
> USB disk for missing files or files that need to be removed.
>
>
>
> Kind regards
>
> Johnny Rosenberg
> ジョニー・*ーゼンバーグ
>
> --
> ubuntu-users mailing list
> ubuntu-users@lists.ubuntu.com
> Modify settings or unsubscribe at: https://lists.ubuntu.com/mailman/listinfo/ubuntu-users

Are you currently using rsync or just a cp command? If you're not
using rsync I'd definitely be looking into that.

--
Regards,

Jared Norris
https://wiki.ubuntu.com/JaredNorris

--
ubuntu-users mailing list
ubuntu-users@lists.ubuntu.com
Modify settings or unsubscribe at: https://lists.ubuntu.com/mailman/listinfo/ubuntu-users
 
Old 09-16-2012, 10:32 PM
"Juan R. de Silva"
 
Default Quick backup

On Mon, 17 Sep 2012 06:49:07 +1000, Jared Norris wrote:

> Are you currently using rsync or just a cp command? If you're not using
> rsync I'd definitely be looking into that.

+

rsync is definitely way to go. I use a script that utilizes rsync to make
a shapshot like backups (you can google for this). The script is run by
cron daily and rsync produces a log with the full list of what has been
changed, deleted, etc. The daily backup is stored on a separate
partition. Currently I store only last 4 days in the backup set. This can
be changed easily by changing a variable in the script at any time to
your likes.

Then twice a week I run another script (I run this one manually), that is
just a slight modification of the first one, to move the full set of
backups to an external USB drive where I also keep 4 last backup sets.

Since both scripts use rsync, if the changes are minimal the time to make
backup and/or to move a backup set to USB drive is minimal as well.



--
ubuntu-users mailing list
ubuntu-users@lists.ubuntu.com
Modify settings or unsubscribe at: https://lists.ubuntu.com/mailman/listinfo/ubuntu-users
 
Old 09-17-2012, 02:53 PM
Preston Hagar
 
Default Quick backup

On Sun, Sep 16, 2012 at 2:11 PM, Johnny Rosenberg
<gurus.knugum@gmail.com> wrote:
> I wrote a backup Bash-script many years ago. I could just run a script that reads that
> file and copy only those files to their corresponding places on that
> USB drive (reminding me to turn it on if I didn't - something that my
> present backup script already does).
>
>
> Kind regards
>
> Johnny Rosenberg
> ジョニー・*ーゼンバーグ

Below is a basic version the script I use both personally and for
several servers for backups. It uses cp -al which creates hard links
to do daily snapshots and rsync to only copy changed files. What hard
links give you is that if a file is unchanged, it doesn't create a
second copy. That means each daily snapshot only takes up the space
(roughly) of the day's changes.

rsync will only copy files that have changed on the source to the
destination, so it sounds pretty much exactly like what you want,
without the log file hacking.

(Side Note: I'm pretty sure rsync has hard linking capabilities in it
now. I have had this script around so long, it didn't when I first
wrote it. It works great as is, but you likely could just do the
whole thing with rsync)

#!/bin/bash

# Daily backup script for Preston

exec > /var/log/backup.log

echo "*****Backup Started: " `date`

# this is the mount point for your USB drive
# here is where you would want to put mount checking code. I
currently don't have that part written.

backup_dir=/mnt/usbdrive

#> Rotate snapshots
echo "Rotating snapshots"
cd $backup_dir/

# I do 7 days worth of snapshots, just add more mv commands and up the
rm command to get more snapshots
rm -rf 7
mv 6 7
mv 5 6
mv 4 5
mv 3 4
mv 2 3
mv 1 2

# Copy the current to the snapshot head
# this will create hard links and from then on, only take up disk
space for things that are different files
# the touch command will set the backup directory's modified date (but
not the files inside) to today, so
# when you do a ls, the date next to the directory (1,2,3,etc.) will
be the date it was created.

cp -al $backup_dir/current $backup_dir/1
touch $backup_dir/current
touch -r $backup_dir/current $backup_dir/1


#> Backup to current
# Here is where I use rsync to backup the directories I want to my backup drive.
# If you don't have too many files, you could likely do this in one big
# rsync command (rsync /var/data/samba for example) but I have found
# that rsync can sometimes overload a system or choke when the file
list is too large, so I tend to
# split it up into several commands if possible and reasonable.

echo "Archiving to backup folder"
rsync -av --delete /var/data/samba/backups $backup_dir/current/
rsync -av --delete /var/data/samba/files $backup_dir/current/
rsync -av --delete /var/data/samba/Pictures $backup_dir/current/
rsync -av --delete /var/data/samba/digital scrapbook $backup_dir/current/
rsync -av --delete /var/data/samba/scans $backup_dir/current/

echo "*****Backup Completed: " `date`


# end of script


Hope that helps out.

--
ubuntu-users mailing list
ubuntu-users@lists.ubuntu.com
Modify settings or unsubscribe at: https://lists.ubuntu.com/mailman/listinfo/ubuntu-users
 

Thread Tools




All times are GMT. The time now is 11:56 PM.

VBulletin, Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.
Copyright 2007 - 2008, www.linux-archive.org