Results 1 to 3 of 3
Hi Friends,
I need help. I have around 100 users. I want to take backup of files which are on desktop for every user.
My user directory path is -: ...
- 04-21-2011 #1Just Joined!
- Join Date
- Apr 2011
- Posts
- 22
Script for taking backup of desktop files.
Hi Friends,
I need help. I have around 100 users. I want to take backup of files which are on desktop for every user.
My user directory path is -: /home/dr/<user_name>/Desktop
1) Script has to run on a particular time everyday
2) Script has to take backup of all files present in "Desktop" directory
3) Make a tar with name "yyyy-mm-dd-desk-files"
4) Make directory outside "Desktop" with name "Desktop-Backup", if already exist then don't make this folder.
5) The tar have to moved in this folder.
6) Remove the files from "Desktop" directory. (i.e. Desktop should be empty)
7) Mail the status that "Backup Successful"
- 04-21-2011 #2Just Joined!
- Join Date
- Apr 2011
- Posts
- 14
To run a command at a specific time of day, I recommend you lookup cron. To backup your files, one of the most popular methods is to use rsync. You can send an email from the command line using sendmail. Once you have looked each of those up, try writing the script on your own and report back if you run in to any trouble.
- 04-21-2011 #3Just Joined!
- Join Date
- Apr 2011
- Posts
- 22
I made one script......
#! /bin/bash
# Variables
location=/home/dr/parag.n/Desktop
directory=*
backuplocation=/home/dr/parag.n
log=/home/dr/parag.n/backup.log
echo -e “\nBackup started: `date`” >> $log
if [ -d $backuplocation ]; then
mkdir -p $backuplocation/`date +%y-%m-%d`
cd $location
tar -zcvf $backuplocation/`date +%y-%m-%d`/Desktop-Files.`date +%H-%M-%S`.tar.gz $directory
rm -fr *
echo ” completed: `date`” >> $log
mv $log $backuplocation/backup.log
echo -e “\n — Backup completed –\n”;
else
echo ” FAILED: `date`” >> $log
echo -e “\n– WARNING: –”
echo -e “– BACKUP FAILED –\n”;
fi
In this "parag.n" is my home directory. But I have many users. How can i take backup of all of them? & How could i get a mail after finishing backup?


Reply With Quote