I have to write a shell script that archives pictures stored in a directory.
within my /home/pictures directory, jpegs get saved.
Once the folder gets large enough (100MB), I would like to make a tar.gz archive all the files located in the directory, and move them to /home/archives.
How would I go about writing a shell script/cron job to perform this?
#!/bin/bash
# Backup Script
echo "\nWelcome to the backup script\n"
cd /home/images
if [$du -h /home/images] >= 100MB ; then
tar -pczf `date`.tar.gz /home/pictures/backup
fi
exit 0;
#!/bin/bash
# Backup Script
echo "\nWelcome to the backup script\n"
path="/home/images"
if [ `du -ms $path` > 1000 ] ; then
find $path > /tmp/list.txt
tar -T /tmp/list.txt -pczf `date`.tar.gz
for i in `cat /tmp/list.txt`; do
rm -rf $i
done
fi
exit 0;
Recent comments
1 day 6 hours ago
1 day 11 hours ago
1 day 15 hours ago
1 day 17 hours ago
2 days 7 hours ago
2 days 7 hours ago
2 days 12 hours ago
2 days 19 hours ago
2 days 20 hours ago
2 days 21 hours ago