Solved

back up homre directory on debian

Posted on 2006-06-27
2
226 Views
Last Modified: 2013-11-15
Are there any method to backup /home dirdctory to another hardisk every day by change the name of target everyday after
3 day then replace the old one   i run on debian


suchas

 on 1 jul backupas          01.tar
on 02 jul back up as        02.tar
on 03 jul backup as          03.tar

on 04 jul backupas          01.tar
on 05 jul back up as        02.tar
on 06 jul backup as          03.tar

Thank
0
Comment
Question by:teera
  • 2
2 Comments
 
LVL 22

Accepted Solution

by:
pjedmond earned 450 total points
ID: 16995609
Assuming that your remote directory is mounted in some way, then:

----------8X----------------------------
#!/bin/bash
NAME=`ls -act /backup/dir | grep *.tar | tail -n1`        #This finds the oldest tar file in /backup/dir
tar -cvf /backup/dir/NAME /home                                #This backs up the home directory
----------8X----------------------------

You need to 'prime' /backup/dir as follows:

touch /backup/dir/01.tar
touch /backup/dir/02.tar
touch /backup/dir/03.tar

Oldest file will then initially be 01.tar for first backup etc.

Finally, add the above script to your crontab, in order to ensure that it runs once per day at a suitable time:

12 12 * * * /dir/to/myscript.sh

(   (()
(`-' _\
 ''  ''

0
 
LVL 22

Assisted Solution

by:pjedmond
pjedmond earned 450 total points
ID: 16995617
Ooooops - change script to:

----------8X----------------------------
#!/bin/bash
NAME=`ls -act /backup/dir | grep *.tar | tail -n1`        #This finds the oldest tar file in /backup/dir
rm -Rf /backup/dir/NAME                                            #Remove the old file!
tar -cvf /backup/dir/NAME /home                                #This backs up the home directory
----------8X----------------------------
(   (()
(`-' _\
 ''  ''
0

Featured Post

Enterprise Mobility and BYOD For Dummies

Like “For Dummies” books, you can read this in whatever order you choose and learn about mobility and BYOD; and how to put a competitive mobile infrastructure in place. Developed for SMBs and large enterprises alike, you will find helpful use cases, planning, and implementation.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

It’s 2016. Password authentication should be dead — or at least close to dying. But, unfortunately, it has not traversed Quagga stage yet. Using password authentication is like laundering hotel guest linens with a washboard — it’s Passé.
Fine Tune your automatic Updates for Ubuntu / Debian
Learn how to navigate the file tree with the shell. Use pwd to print the current working directory: Use ls to list a directory's contents: Use cd to change to a new directory: Use wildcards instead of typing out long directory names: Use ../ to move…
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.

948 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now