Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

back up homre directory on debian

Posted on 2006-06-27
2
Medium Priority
?
236 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 1800 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 1800 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

NEW Veeam Agent for Microsoft Windows

Backup and recover physical and cloud-based servers and workstations, as well as endpoint devices that belong to remote users. Avoid downtime and data loss quickly and easily for Windows-based physical or public cloud-based workloads!

Question has a verified solution.

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

The purpose of this article is to show how we can create Linux Mint virtual machine using Oracle Virtual Box. To install Linux Mint we have to download the ISO file from its website i.e. http://www.linuxmint.com. Once you open the link you will see …
Google Drive is extremely cheap offsite storage, and it's even possible to get extra storage for free for two years.  You can use the free account 15GB, and if you have an Android device..when you install Google Drive for the first time it will give…
Learn several ways to interact with files and get file information from the bash shell. ls lists the contents of a directory: Using the -a flag displays hidden files: Using the -l flag formats the output in a long list: The file command gives us mor…
Learn how to find files with the shell using the find and locate commands. Use locate to find a needle in a haystack.: With locate, check if the file still exists.: Use find to get the actual location of the file.:
Suggested Courses
Course of the Month9 days, 22 hours left to enroll

926 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