is there a way or perhaps a script that the files from the server can be archive or be zipped?
Printable View
is there a way or perhaps a script that the files from the server can be archive or be zipped?
You could use tar to make an archive. Although, I am really not sure exactly what you are trying to do...
Ubuntu is a little different from most distros, but I'm pretty sure it still has the base Linux installation stuff, which means if you need to do this you shouldn't need any extra software. Tar was mentioned already and is an easy to basically make a huge file of a bunch of other files, and then you can gzip it into a little tar.gz file, which is a gzipped tarball.
Also, you can use bunzip2 which has better compression normally, but also takes longer to make the file.
And 7Zip generally comes with most Linux distros. try this:
apt-get install 7zip
If it doesn't work, or says it's already installed you're done there and can use that, or, just use that normal tar and gzip.
my boss actually needs this or (or maybe he knows already and wants to test me) and he wants me to find script or a command on the cronjobs that can zip, gzip, tar.
Managers are idiots. He's probably thinking Winzip. Which works on Windows. ;)
In all seriousness, if you need to find this in a CronJob....Well, go to /etc:
cd /etc
Then read what Cron Jobs have been set already and see if there is one someone added in there that actually does this, or you could, well, I guess you could add one where you zipped up certain files and directories, most distros come already with zip and Gzip now, bit the standard one that's normally there is gzip.
For multiple files, remember to tar them first
you can check out more with this:
man tar
man gzip
For large compressed files, I prefer bzip2. Better compression, but you pay for it somewhat in longer comp/decomp wall times. google "bzip2 vs gzip" if you want to understand in more detail.
man bzip2
You could easily use "tar -cf <name-of-tar> <things-to-backup> to gather all thath needs to be backed up.
From the other hand you could rsync to a disk or another server. For example, I have a script to backup to my USB-drive. The script is not entirely finished but it works.
It only adds/deletes/updates files depending on what has happened with a file.
For the reference, if you can do anything with it (I'm not a good scripter :) ):
Quote:
#!/bin/bash
DRIVE_SERIAL="<serialnumber-of-the-usb-drive"
DETECTION=`cat /proc/bus/usb/devices | grep SerialNumber=$DRIVE_SERIAL`
LOGFILE=/var/scripts/backup.log
RSYNC_TIMESTAMP=`date "+%d%m%y"`
RSYNC_LOGFILE="/var/scripts/rsync_$RSYNC_TIMESTAMP.log"
BUSYFILE=/var/scripts/backup.busy
if [ "$DETECTION" == "" ]; then
echo "`date "+%b %d %H:%m:%S"` - USB-drive not attached. Exit." >> $LOGFILE
else
echo "`date "+%b %d %H:%m:%S"` - USB-drive found !" >> $LOGFILE
echo "`date "+%b %d %H:%m:%S"` - Checking for running jobs ..." >> $LOGFILE
if [ -f "$BUSYFILE" ]; then
echo "`date "+%b %d %H:%m:%S"` - Busy-file found !" >> $LOGFILE
echo "`date "+%b %d %H:%m:%S"` - Another backup already in progress. Exit." >> $LOGFILE
exit
else
echo "`date "+%b %d %H:%m:%S"` - Busy-file not found. Good. Proceeding to backup." >> $LOGFILE
echo "1" >> $BUSYFILE
echo "`date "+%b %d %H:%m:%S"` - Mounting USB-drive ..." >> $LOGFILE
mount -t ntfs-3g /dev/sdc1 /mnt/backup
echo "`date "+%b %d %H:%m:%S"` - RSYNC Started." >> $LOGFILE
rsync -vrlptg --log-file=$RSYNC_LOGFILE /xen/ /mnt/backup/Backup/xen
rsync -vrlptg --log-file=$RSYNC_LOGFILE /raid3/ /mnt/backup/Backup/data
echo "`date "+%b %d %H:%m:%S"` - RSYNC Finished." >> $LOGFILE
echo "`date "+%b %d %H:%m:%S"` - Unmounting drives ..." >> $LOGFILE
umount /dev/sdc1
echo "`date "+%b %d %H:%m:%S"` - Releasing BACKUP_BUSY variable ..." >> $LOGFILE
rm $BUSYFILE
fi
fi
thanks for the tip. always been helpful. i'll make use of this script and perhaps expand to what i know. thank you.