Sponsored Content
Full Discussion: Smart Backup Script
Top Forums Shell Programming and Scripting Smart Backup Script Post 302467877 by TheGacko on Sunday 31st of October 2010 09:07:22 PM
Old 10-31-2010
thanks for the reply

yeah sorry copied wrong command.. ls command should have -t switch to sort by time.

this is a ubuntu lucid server box

ok to give some stuff im getting. a straight df command gives me
Code:
Filesystem           1K-blocks      Used Available Use% Mounted on
/dev/md0             230582364  41795744 177073652  20% /
none                   2020888       220   2020668   1% /dev
none                   2025440         0   2025440   0% /dev/shm
none                   2025440      1708   2023732   1% /var/run
none                   2025440         0   2025440   0% /var/lock
none                   2025440         0   2025440   0% /lib/init/rw
/dev/sdd1            488384032     81104 488302928   1% /media/usb0

im only interested in the usb drive and the free space. (i was trying to maybe use percentage but that will be to complicated). I grep "usb" although I could make this more accurate. so this gives me.

Code:
df |grep usb |awk '{print $4}'

which in the above example will give me

Code:
488302928

sweet the free space in kilobytes. using this I want to compare to an amount of free space I want to have available, say 20G or ~20000000 kilobytes (clearly its all good at the moment but will fill up)

now the file i want to remove can be identified with

Code:
ls -t *.tgz |tail -n1

on whichever the folder im interested in removing files.

Thanks for the example code but I really dont understand a lot of it. not sure what the "next" command is (or is it a variable). and dont see how it checks

the way I have done it before is to basically

: start
check if more than 20G available
>> if false remove oldest backup file and goto start
>> if true, out of loop, carry on with backup

so Ive got the checking if 20G down pat and ive got the removing oldest file down pat but i haven't got the looping.

ive looked at other examples of backup scripts but a lot are looking to just say keep only 4 backups on media etc not dynamically working out how much space is needed.

cheers,
 

7 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

smart script?

First, I know that's a bad title. I couldn't think of anything short enough. ... I wrote the following script to let me know when various parts of the network are down. It used to look like this before last weekend when I got over 500 emails about 1 host being down all weekend: this is in the... (1 Reply)
Discussion started by: raidzero
1 Replies

2. UNIX for Dummies Questions & Answers

Explain the difference between the commands cd ~smart and cd ~/smart

Is it possible for both commands to work? (1 Reply)
Discussion started by: phunkypants
1 Replies

3. Shell Programming and Scripting

rsync backup mode(--backup) Are there any options to remove backup folders on successful deployment?

Hi Everyone, we are running rsync with --backup mode, Are there any rsync options to remove backup folders on successful deployment? Thanks in adv. (0 Replies)
Discussion started by: MVEERA
0 Replies

4. Shell Programming and Scripting

Need help in creating file restoration script from a backup script.

Hi all i am struggling in creating a restore of env files while doing applications clone. the first file i created for copying the important configurations file which is running perfect now for reverting the changes i mean when i am restoring these files to its original places i have to do... (7 Replies)
Discussion started by: javeedkaleem
7 Replies

5. Shell Programming and Scripting

Need smart script !

Hi, I need a script to assign variables the below paths /appl/user_projects/domains/<xxx>/servers/<yyy>/logs Where <xxx> can be any number and name of directories. <yyy> can be another set of any number of names and directories. I want to neglect all the <xxx> and <yyy>... (3 Replies)
Discussion started by: mohtashims
3 Replies

6. Shell Programming and Scripting

Help with Backup Shell Script for Network Device Configuration backup

HI all, im new to shell scripting. need your guidence for my script. i wrote one script and is attached here Im explaining the requirement of script. AIM: Shell script to run automatically as per scheduled and backup few network devices configurations. Script will contain a set of commands... (4 Replies)
Discussion started by: saichand1985
4 Replies

7. Shell Programming and Scripting

Shell script to call Oracle archive backup script when file system reaches threshold value

Hello All, I need immediate help in creating shell script to call archivebkup.ksh script when archive file system capacity reaches threshold value or 60% Need to identify the unique file system that reaches threshold value. ex: capacity ... (4 Replies)
Discussion started by: sasikanthdba
4 Replies
AMZFS-SNAPSHOT(8)					  System Administration Commands					 AMZFS-SNAPSHOT(8)

NAME
amzfs-snapshot - Amanda script to create zfs snapshot DESCRIPTION
amzfs-snapshot is an Amanda script implementing the Script API. It should not be run by users directly. It create a zfs snapshot of the filesystem where the path specified is mounted. PRE-DLE-* create a snapshot and the POST-DLE-* destroy the snapshot, *-DLE-AMCHECK, *-DLE-ESTIMATE and *-DLE-BACKUP must be set to be executed on the client: execute-on pre-dle-amcheck, post-dle-amcheck, pre-dle-estimate, post-dle-estimate, pre-dle-backup, post-dle-backup execute-where client The PRE_DLE_* script output a DIRECTORY property telling where the directory is located in the snapshot. The application must be able to use the DIRECTORY property, amgtar can do it. The script is run as the amanda user, it must have the priviledge to create and destroy snapshot: zfs allow -ldu AMANDA_USER mount,snapshot,destroy FILESYSTEM Some system doesn't have "zfs allow", but you can give the Amanda backup user the rights to manipulate ZFS filesystems by using the following command: usermod -P "ZFS File System Management,ZFS Storage Management" AMANDA_USER This will require that your run zfs under pfexec, set the PFEXEC property to YES. The format of the DLE must be one of: Desciption Example ---------- ------- Mountpoint /data Arbitrary mounted dir /data/interesting_dir ZFS pool name datapool ZFS filesystem datapool/database ZFS logical volume datapool/dbvol The filesystem must be mounted. PROPERTIES
This section lists the properties that control amzfs-snapshot's functionality. See amanda-scripts(7) for information on the Script API, script configuration. DF-PATH Path to the 'df' binary, search in $PATH by default. ZFS-PATH Path to the 'zfs' binary, search in $PATH by default. PFEXEC-PATH Path to the 'pfexec' binary, search in $PATH by default. PFEXEC If "NO" (the default), pfexec is not used, if set to "YES" then pfexec is used. EXAMPLE
In this example, a dumptype is defined to use amzfs-snapshot script to create a snapshot and use amgtar to backup the snapshot. define script-tool amzfs_snapshot { comment "backup of zfs snapshot" plugin "amzfs-snapshot" execute-on pre-dle-amcheck, post-dle-amcheck, pre-dle-estimate, post-dle-estimate, pre-dle-backup, post-dle-backup execute-where client #property "DF-PATH" "/usr/sbin/df" #property "ZFS-PATH" "/usr/sbin/zfs" #property "PFEXEC-PATH" "/usr/sbin/pfexec" #property "PFEXEC" "NO" } define dumptype user-zfs-amgtar { dt_amgtar script "amzfs_snapshot" } SEE ALSO
amanda(8), amanda.conf(5), amanda-client.conf(5), amanda-scripts(7) The Amanda Wiki: : http://wiki.zmanda.com/ AUTHORS
Jean-Louis Martineau <martineau@zmanda.com> Zmanda, Inc. (http://www.zmanda.com) Dustin J. Mitchell <dustin@zmanda.com> Zmanda, Inc. (http://www.zmanda.com) Amanda 3.3.3 01/10/2013 AMZFS-SNAPSHOT(8)
All times are GMT -4. The time now is 07:25 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy