Sunday, May 5, 2024
 Popular · Latest · Hot · Upcoming
2
rated 0 times [  2] [ 0]  / answers: 1 / hits: 2843  / 2 Years ago, sun, may 1, 2022, 8:49:04

I want to backup my whole linux server but where do i --exclude=proc --exclude=sys --exclude=dev/pts --exclude=/var/backups . Please help!!!



Here is my code. I may also have some errors in it. Feedback is welcome.....



#!bin/bash
#Purpose = Backup of var directory

TIME=`date +"%b-%d-%y"` # This Command will add date in Backup File Name.
FILENAME="backup-$TIME.tar.gz" # Here i define Backup file name format.
SRCDIR="/ " # Location of Important Data Directory (Source of backup).
DESDIR="/var/backups/fullbackup" # Destination of backup file.
LOGSYS="/var/log/fullbackup" #Log files of the backup.

echo "Starting backup of $SRCDIR to $DESDIR on $TIME" >> ${LOGSYS}
tar -cpzf $DESDIR/$FILENAME $SRCDIR
echo "Ending backup of $SRCDIR on $TIME" >> ${LOGSYS}

#END

More From » backup

 Answers
4

You list all the directories to be excluded into a text file, like this :



/var/backups
/proc
/sys
/dev
/tmp


Let's call this file /etc/backup-excl.lst



Then you can call the tar command the following way :



tar ScpfzX /etc/backup-excl.lst $DESTDIR/$FILENAME $SRCDIR


The X parameter flas is to tell that a file with directories to be excluded will follow.



The S parameter is used to handle Linux sparse files smartly. Sparse files are files which contain empty space, where the disk space is pre-allocated but not necessarily used. Handling these files smartly means only backuping the real content, not the empty space.


[#23648] Monday, May 2, 2022, 2 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
ndeecru

Total Points: 109
Total Questions: 128
Total Answers: 117

Location: Czech Republic
Member since Thu, Aug 11, 2022
2 Years ago
ndeecru questions
Mon, Jun 20, 22, 04:53, 2 Years ago
Thu, Mar 10, 22, 18:53, 2 Years ago
Thu, Oct 14, 21, 20:53, 3 Years ago
Thu, Apr 28, 22, 10:16, 2 Years ago
;