snap_charge -- add together charges for snapback2


snap_charge [-p|-i] [-c client] [-y year] [-m month] <chargefile>


When passed a snapback2 charge log filename, compiles and prints a report. The report will be in N.N[KMGT] format, i.e:

        100  is 100 bytes
        100K is 100 kilobytes where a kilobyte is 1024 bytes
        100M is 100 megabytes where a megabyte is 1024 kilobytes
        100G is 100 gigabytes where a gigabyte is 1024 megabytes
        100T is 100 terabytes where a terabyte is 1024 gigabytes

The charges are based on the bytes read statement returned by rsync at backup time. All directories under a client domain name are added together.


-c client

Selects one client domain to report for. If passed -p, -i, or -y YYYY and -m MM, prints only the number of bytes for that month and nothing else. If no year/month combination (that includes -i or -p) is sent, then prints a tab-delimited numeric report line for each month:


Implies the -n option.


Summarize charges for current month -- same as passing -y and -m set to the current year and month.

-m MM

The month to report on. Requires -y.


Print numbers only. Forced if -c option is passed. Otherwise, the report looks like: in 2004-01: 288.6M in 2004-01: 8.5G in 2004-01: 1.2T

Summarize charges for last month -- same as passing -y and -m set to the previous month (and year if in January).


The year to report on.


Should be enhanced to read snapback2 configuration file and figure out the charge log. That will happen when the functions of snapback2 are modularized -- if they ever are.


Mike Heins, <>.