Senin, 04 April 2011

Faktor kunci sukses dalam e-commerce

Dalam banyak kasus, sebuah perusahaan e-commerce bisa bertahan tidak hanya mengandalkan kekuatan produk saja, tapi dengan adanya tim manajemen yang handal, pengiriman yang tepat waktu, pelayanan yang bagus, struktur organisasi bisnis yang baik, jaringan infrastruktur dan keamanan, desain situs web yang bagus, beberapa faktor yang termasuk:
Menyediakan harga kompetitif
Menyediakan jasa pembelian yang tanggap, cepat, dan ramah.
Menyediakan informasi barang dan jasa yang lengkap dan jelas.
Menyediakan banyak bonus seperti kupon, penawaran istimewa, dan diskon.
Memberikan perhatian khusus seperti usulan pembelian.
Menyediakan rasa komunitas untuk berdiskusi, masukan dari pelanggan, dan lain-lain.
Mempermudah kegiatan perdagangan

Aplikasi Bisnis E-Commerce

Beberapa aplikasi umum yang berhubungan dengan e-commerce adalah:
E-mail dan Messaging
Content Management Systems
Dokumen, spreadsheet, database
Akunting dan sistem keuangan
Informasi pengiriman dan pemesanan
Pelaporan informasi dari klien dan enterprise
Sistem pembayaran domestik dan internasional
Newsgroup
On-line Shopping
Conferencing
Online Banking/internet Banking
Product Digital/Non Digital

Senin, 21 Maret 2011

Tentang E-Commerce


Electronic commerce, yang biasa dikenal sebagai e-comm, e-commerce atau eCommerce, terdiri dari pembelian dan penjualan produk atau layanan melalui sistem elektronik seperti internet dan jaringan komputer lainnya. Jumlah perdagangan dilakukan secara elektronik telah berkembang luar biasa dengan penggunaan internet yang meluas. Penggunaan perdagangan dilakukan dengan cara ini, memacu dan menggambar pada inovasi dalam transfer dana elektronik, manajemen rantai suplai, pemasaran Internet, proses transaksi online, pertukaran data elektronik (EDI), inventarisasi sistem manajemen, dan sistem pengumpulan data otomatis. Perdagangan elektronik modern biasanya menggunakan World Wide Web setidaknya di beberapa titik dalam siklus transaksi itu, meskipun dapat mencakup berbagai teknologi yang lebih luas seperti e-mail, perangkat mobile dan telepon juga.
Sebagian besar elektronik commerce dilakukan sepenuhnya elektronik untuk virtual seperti akses ke konten premium pada sebuah situs web, namun sebagian besar elektronik commerce melibatkan transportasi fisik item dalam beberapa cara. Online pengecer kadang-kadang dikenal sebagai e-tailers dan eceran online kadang dikenal sebagai e-ekor. Hampir semua pengecer besar telah elektronik commerce keberadaan di World Wide Web.
Elektronik commerce yang dilakukan antara perusahaan yang disebut sebagai usaha-usaha atau B2B. B2B dapat terbuka untuk semua pihak yang berkepentingan (misalnya pertukaran komoditi) atau terbatas pada spesifik, pra-kualifikasi peserta (swasta pasar elektronik). Elektronik commerce yang dilakukan antara perusahaan dan konsumen, di sisi lain, ini disebut sebagai bisnis-konsumen-atau B2C. Ini adalah jenis electronic commerce yang dilakukan oleh perusahaan seperti Amazon.com. belanja online adalah suatu bentuk perdagangan elektronik di mana pembeli langsung secara online ke komputer penjual biasanya melalui internet. Tidak ada pelayanan perantara. Transaksi jual beli selesai elektronik dan interaktif secara real-time seperti Amazon.com untuk buku-buku baru. Jika perantara hadir, maka penjualan dan transaksi pembelian disebut perdagangan elektronik seperti eBay.com.
Elektronik commerce umumnya dianggap sebagai aspek penjualan e-bisnis. Hal ini juga terdiri dari pertukaran data untuk memfasilitasi pembiayaan dan pembayaran aspek dari transaksi bisnis.

Senin, 30 November 2009

OOM in linux

If the Linux system running out of memory, or a condition called OOM (out of memory), then the "OOM killer" Linux kernel will work, kill the processes of "random" (actually, the processes that deserve to be killed according to certain criteria) to a number of memory is freed and the system can continue to return. But the problem is, sometimes an important process that can be killed. For example: xlock (for lock X session), as a result of our X session to be open by itself. This is fatal, because if we leave our workstations we are the key, so it can open. Another example is the sshd on the remote server, so we lose the remote access server for the.

To overcome this problem, there are several ways / approaches.
Contents

* 1 Panic and automatic reboot
* 2 Setting kernel overcommit
* 3 oom_adj
* 4 References / links

Panic and automatic reboot

We can choose if there OOM condition, automatic kernel panic and reboot it. To do this:

# Echo 1> / proc / sys / vm / panic_on_oom
# Echo 5> / proc / sys / kernel / panic

This means that, within 5 (five) seconds after a kernel panic, direboot automated system. Note: if the kernel or a total hang the machine, of course not automatic reboot. Automatic rebooting could have done if the kernel panic (fatal error) but the kernel is still alive.

To make this setting permanent, add the line:

vm.panic_on_oom = 1
kernel.panic = 5

to / etc / sysctl.conf.

Note: the automatic settings can also be added to the kernel options, namely "panic = N '. In this way we can choose whichever kernel you want to be given this setting and which ones do not. To use the kernel options for autoreboot kernel panic, throw back the line "kernel.panic = 5" from / etc / sysctl.conf and edit / boot / grub / menu.lst and add "panic = 5" in position as below. Note that this menu.lst specific format that will be processed by a script, so the line "kopt =..." after the added "panic = 5" keep dikomen, will be automatically added to each entry is the kernel after we run the script update-grub.

# # # BEGIN AUTOMAGIC kernels LIST
# # Lines between the AUTOMAGIC kernels LIST markers will be modified
# # By the debian update-grub script except for the default options below

# # Uncomment NOT DO THEM, Just edit them to your needs

# # # # Start Default Options # #
# # Default kernel options
# # Default kernel options for automagic boot options
# # If you want special options for specific kernels use kopt_x_y_z
# # Where x.y.z is kernel version. Minor versions can be omitted.
# # E.g. kopt = root = / dev/hda1 ro
# # Kopt_2_6_8 = root = / dev/hdc1 ro
# # Kopt_2_6_8_2_686 = root = / dev/hdc2 ro
# Kopt = root = / dev/hda1 ro panic = 5

Then run update-grub and reboot the kernel.
Setting kernel overcommit

In addition to the first by the panic + autoreboot, we can also set the memory overcommit settings.

# Echo 2> / proc / sys / vm / overcommit_memory

To make this setting permanent, add this line in / etc / sysctl.conf:

vm.overcommit_memory = 2

and reboot the kernel.

This setting prohibits excessive memory allocation by the processes so that the effect of processes not in-kill in OOM conditions but will receive an error message out of memory. For more details, see the Linux kernel documentation in Documentation / vm / overcommit-accounting.

We have a system that uses Spanel 1.2 set using this setting.
oom_adj

Specific processes can be protected from the "massacre" by the OOM by setting:

# Echo -17> / proc / / oom_adj

where is the process ID concerned. Child process will inherit these settings oom_adj.

Note: the Spanel 1.2, boot script / etc / init.d / ssh has added the following lines like this:

echo -17> / proc / `cat / var / run / sshd.pid` / oom_adj

protecting sshd from OOM killer.
References / links

* Documentation Linux kernel VM subsystem (subdirectory Documentation / vm)
* Search engines with keywords such as:
o oom handling condition on linux
o oom_adj
o oom_pardon (another unofficial patch in Linux to protect the process from the OOM killer; who entered Linux is oom_adj)
o automatic kernel panic reboot

Explanation of common error messages in Linux

As a beginner, you would sometimes get confused with some error messages in the Linux shell command line is quite short with no explanation. For example, when you want to run a command, the result is "Permission denied". But exactly why permission denied, when you are logged in as root, which should have been able to do anything? Or "command not found". How? Though the name is correct according to instructions in the book / manual, not a typo.

This article describes some common error messages in more detail: mean error messages, some common causes of the emergence of these error messages, along with tips that are relevant.
Command not found

This error message appears if the shell can not find the command you want.

One of the most common cause for beginners, indeed, is the wrong type or forget what the exact command name. The names of the Linux command sometimes "kriptik" or weird, so hard to remember. Some very abbreviated command name, a short course of 2-3 letters, because the first was in Unix memory and disk space is very very limited so that all superpendek department. Contohlah: ls, pwd, du, df. Not only beginners, even veteran users sometimes forget to various commands or scripts that numbering thousands. Say a2ensite or a2dismod, two helper scripts in Debian which very often I forget until now. Not to mention sometimes every distro has a different command name: the distribution of a "useradd", on the other "adduser".

Another cause is indeed the program you want is not installed. When you install a new system, sometimes the default settings of the distribution is minimalist. A good policy, though. For example, when installing a Debian system without a GUI and many frills, and even less any such orders not yet exist. Especially popular utilities such as wget or mc or your favorite editor, which must be installed first. How to install it outside the discussion of this article, because it varies according to distribution (apt-get, yum, click, etc.) and taste (GUI, TUI, or command line).

Other causes of common, but the program is located in the shell does not search. Please note that when you type in the name of a shell command like this:

$ Beats

So bash shell as usual for this knock on the list of functions or aliases that have been defined previously, or programs or scripts called beats in the filesystem. For program or script that is in the filesystem, the shell will look only at specific locations which are defined according to the PATH environment variable. Let us look at the contents of PATH:

$ Echo $ PATH
/ usr / local / bin: / usr / bin: / usr/bin/X11: / bin

Means is, the shell will only find in the directory / usr / local / bin, / usr / bin, / usr/bin/X11, and / bin, in that order. The programs in other locations, such as / sbin, / usr / sbin, / opt/VirtualBox-1.3.8, even in the current directory that you are (current directory) will be ignored. So you may be confused, how programs that are in front of the eyes, that if the "ls" are clearly there, when they want to be executed kok still considered "not found"?

To execute programs outside the standard location in the PATH, you can mention the location before the name of the program, for example:

$ / Opt/Ketuk-1.2/bin/ketuk

Or if you are currently located in the directory / opt/Ketuk-1.2/doc, you can use the relative location:

$ .. / Bin / tap

One common case is: in some distros, if you change to root (using the command "su"), then the PATH has not changed. As a result, if you try to run the command:

# Traceroute www.google.com

the shell did not find this traceroute program, which is generally located in / usr / sbin, which is not listed in the standard normal users PATH. To get root's PATH that contains the locations sbin: / sbin, / usr / sbin, / usr / local / sbin then switch to root when you need to use the command "su -".

By the way, why the behavior of such shells, only to find programs in the PATH? The first, obviously, so that the program search process did not take too long. In a system there could be hundreds to thousands of directories and there is no index to its real time, too time-consuming if a shell trying to trace all these directories one by one.

Another reason is, in the case of current directory, for security. The program will only be sought in a particular location is known and safe (/ usr / bin, / bin, etc.). Current directory sometimes "not safe". You could be walking into / tmp or other user's directory. Aja could have a program called "ls", "cat", "less" in that directory but it is entirely different. Now imagine you're an admin or staff shared hosting, and one of your users pretending to ask for help you to see an own directory, with the goal of keeping you "accidentally" run program "ls", gratitude-gratitude as root. This program may be intended to install malware or install a backdoor for the user. Well, have not understood why the default shell does not include the current directory in the PATH?

For the record, to execute a command in the current directory, use the syntax:

$. / Tap

And if you still insist want to be able to execute programs that have a plain current directory, then you can add this current directory (".") to the PATH, for example:

$ Export PATH = "$ PATH:."

Command can be added eg to ~ /. Bash_profile you to be executed each time you login. Keep in mind that adding the current directory to the PATH so is not recommended because of security risks, especially if it is done for the root user.
Permission denied

This error message appears if you are deemed not to have sufficient rights to run the program.

Some programs, especially the nature setuid, protected from certain users or groups. For example:

$ Ls-l / bin / su
-rwsr-x --- 1 root su-users 27000 2006-12-08 01:28 su

Here seen that only root and members of the group "su-users" are allowed to access / bin / su.

Sometimes you have a new program or upload your coffee can not be executed with the permissions denied error message is. This is generally because there is no file permissions bits x (execute), examples of 0644 and not 0755:

$ Ls-l tap
-rw-r - r - 1 steven steven tap 373 2007-05-05 06:42

To run a program, it takes bits x (execute) the permissions. Even if you root, the kernel will still refuse to execute a program or script that does not have bits of x.

To fix this problem, give bit x in the program:

$ Chmod + x tap
$ Ls-l tap
-rwxr-xr-x 1 steven steven tap 373 2007-05-05 06:42


Note: if the program is a script, then you can also call this script with the interpreter's name begins / programming language. In this way, you do not need a bit of x on the script but just bits r (read) it. For example, if the tap in the above examples are Perl scripts:

$ Perl tap

Connection refused, Connection timed out, Connection reset by peer

Three error messages are also often encountered in working in the network, and the beginner sometimes does not understand the clear meaning and the difference between each other. The cause of the appearance of error messages are indeed diverse.

If translated, "connection refused" means that our connection request is rejected. This generally happens if we want to contact a service that was dead. The point here is to die no program (daemon, a server) that are listening (listen) at the port we want to contact. For example, try contacting a random port on your own computer:

$ Telnet localhost 23056
Trying 127.0.0.1 ...
telnet: Unable to connect to remote host: Connection refused

This is because generally there is no daemon that listen on that port. Unlike for example the common port like 80 (HTTP). If your system already installed the web server:

$ Telnet localhost 80
Connected to localhost.
Escape character is'^]'.

This means we succeeded in connecting to port 80 to talk with the web server. Press Ctrl-] (hold down the Control key followed by the press the "]") to exit.

What if we turn off the webserver? For example:

# / Etc/init.d/apache2 stop

(in particular distro you may use sudo / etc/init.d/apache2 stop).

$ Telnet localhost 80
Trying 127.0.0.1 ...
telnet: Unable to connect to remote host: Connection refused

Now the result is Connection refused, because there is no program listening on port 80 connections. So sometimes this error message can be used for monitoring purposes, as an indication of whether a service life or death.

But it could be a message Connection refused due to a firewall. For example, a rule in the firewall to the remote REJECT packet to port 25, to prevent the program on the local computer to contact the remote SMTP server (and spam, for example). So if we try:

$ Telnet mx.yahoo.com 25
Trying 68.142.195.60 ...
telnet: Unable to connect to remote host: Connection refused

Not necessarily mean that the SMTP service on the Yahoo! dead, but there may be a firewall that makes your connection fails.

"Connection timed out" means that when you try to contact a remote port, no answer back from the other end. The reasons may vary: could be your connection to the remote host is very slow so that the time limit specified connection exceeded. There could also blocked by the firewall to DROP (not to REJECT) packets that are sent so that your connection request is not never got to goal.

What about the "Connection reset by peer"? This error message occurs if the connection to the remote host has happened, but it broke. Causes of rupture could include: programs on remote hosts disconnect intentionally. This too can cause all kinds: IP you disliked by the program, there are already too many connections from IP or block your IP, on the other side of the program was killed because of one thing after another, etc.. Another cause is the internet connection problems, for example, if you are using dialup and telephone lines disconnected or hang up.

In short, if you are experiencing network connection problems, need to see first whether the cause in your system side, on the remote system, or in between (ISP, firewall gateway, proxy, etc).

Creating a WAP site

Basically create a WAP site with a regular site. Upload your files and drawing markup, and if necessary use the script / web application. The difference is, his markup files in WML format and not HTML / XHTML. The pictures in WBMP format and not a GIF / JPG / PNG.

In addition, you need to add. Htaccess in your document root, the contents as follows:

index.wml DirectoryIndex index.html index.php
AddType text / x-hdml hdml
AddType text / wml vnd.wap.wml
AddType text / vnd.wap.wmlscript wmls
AddType image / bmp bmp
AddType image / wbmp vnd.wap.wbmp

DirectoryIndex directive above is useful so that if you accessed a WAP site without the file name, eg: index.wml http://wap.tokoku.com/ then there will also be searched and displayed. If not, then the page will appear autoindex Apache ( "Index of / ..."). The next lines to add the MIME Type WML.

To test your WAP site, can use the WAP browser or WAP phone simulator. Opera browser can be a WAP browser. In Firefox there are extensions wmlbrowser.
FAQ

XXX
See also

* Htaccess

Link

* WML article in Wikipedia, http://en.wikipedia.org/wiki/Wireless_Markup_Language

File system backups using rsync with a history

In another article (see: Using Rsync) has introduced rsync, a popular tool to transfer and synchronize files either locally or network. This article contains a sample application using rsync to perform daily backups with history filesystem.
Understanding history backup

What does that mean backups with history? It means that backups have been done in the previous period (eg, yesterday, 2 days ago, last week, etc.) are not deleted but remain stored. Generally, in the world of IT standards in the corporate backup is to store the latest data backups, 7 daily backups history, history 4 weekly backups, and some historical monthly backups (eg: 12). So that the total period of history is 12 months.

Backup with history is more useful because it can help save data corrupted or deleted but not immediately known. For example you may unknowingly delete a directory that is felt no longer needed because the project is completed. It turned out a month later, the project continued. If you do not store historical backups, so after you delete the directory, daily backups on the run following the latest backup any data will no longer contain the directory data, since the latest backup data follow the latest developments.

Or, say you are using or developing a new version of the program. Apparently after a while just know that these programs contain bugs and little by little destroy or remove a small portion of data. To be sure not to lose valuable data, you want to compare current data with the condition 6 months ago.

Or, you want to go back to the configuration state a week ago before you reinstall the OS. If you backup with history on the directory / etc, it is easy to do. Historical data can simply take the appropriate backups.
Save disk space

Backup with history raises a problem: a swollen disk space. Because we keep a full copy backup every day. Thus, the amount of 100MB of data per week would require backup space 7x100MB = 700MB. Within a month requires 30x100MB = 3GB. Within a year requires 365x100MB = 36GB! What if the data you want backed up even more? How to save disk space?

There are two ways that can be done.

Hard links. The first is by using the 'hard links'. In most file systems, including filesystems are often used in Unix / Linux, a directory entry allowed to refer to the location data (file content) the same as other directory entries. In other words, a copy of the file can have more than one name / location. Example:

$ Ln my data other_location / mydata

This command makes a hard link to my data to lokasi_lain / datasaya. This means that the number of copies of only 1, but referred to two different file name. If we modify one, then both will be modified because in fact they are the same.

Ls-l command to show the number of links that refer to a directory entry:

$ Ls-l my data
-rw-r - r - 2 steven steven my data 149 2007-09-04 17:45

Figure 2 shows that there are two links that refer to this file. If we remove one (or we 'unlink', this is why the delete or delete command in Unix are also called unlink):

$ Rm other_location / mydata

then the number of hard links will be reduced:

$ Ls-l my data
-rw-r - r - 1 steven steven my data 149 2007-09-04 17:45

A file will not be freed until all disknya the directory entries that refer to him missing (in other words, before the hard link to 0). When all was deleted:

$ Rm my data

there was no entry that refers to the contents of the file, and the file becomes inaccessible, and that means the block is occupied by the contents of a file declared free and can be used for other content.

With hard links, we can mengirit disk space. The files that do not change from one version of the backup to the next backup version is the hard links to each other.

Level daily, weekly, monthly. The second way in mengirit disk space is to not save all the history on a daily level. Generally data is already getting old increasingly irrelevant, and should not be stored too 'tight' again. So, to store data over a year, generally not too needed to save 365 pieces daily backups, but just 7 daily backups, 4 weekly backups, and 12 monthly backups. Period covered history remain 12 months, but the number of copies required history is 7 +4 +12 = 23 units. If you just want to keep the 3-month period, the number of copies required history 7 +4 +3 = 14 fruit.

Bagimana how to rotate these levels, if we perform daily backups? Below is the illustration for backups s.d. 3 months. Each number represents the day, the smaller is getting old. To obtain the latest backup (ie the newly done today or at least slow yesterday), you can take the greatest number. Example: in the day-to-1, the latest backup is numbered 1. On day 10, 10 numbered backups, etc.. In contrast, the oldest backup is the smallest number. An asterisk (*) represents a candidate who will be moved to the next level backup.

Day 1:
Daily backups: 1
backup downloads: (not applicable)
monthly backup: (none exists)
Day 2:
Daily backups: 2 1
backup downloads: (not applicable)
monthly backup: (none exists)
Day 7:
Daily backups: 7 6 5 4 3 2 1
backup downloads: (not applicable)
monthly backup: (none exists)
Day 8:
Daily backups: 8 * 7 6 5 4 3 2 1 <- moved to weekly
backup downloads: 1
monthly backup: (none exists)
Day 9:
Daily backups: 9 8 * 7 6 5 4 3 2 <- deleted
backup downloads: 1
monthly backup: (none exists)
Day 15:
Daily backups: 15 * 14 13 12 11 10 9 8 * <- moved to weekly
backup downloads: 8 1
monthly backup: (none exists)
Day 16:
Daily backups: 16 15 * 14 13 12 11 10 9 <- deleted
backup downloads: 8 1
monthly backup: (none exists)
Day 22:
Daily backups: 22 * 21 20 19 18 17 16 15 * <- moved to weekly
backup downloads: 15 8 1
monthly backup: (none exists)
Day 29:
Daily backups: 29 * 28 27 26 25 24 23 22 * <- moved to weekly
backup downloads: 22 15 8 1
monthly backup: (none exists)
Day 36:
Daily backups: 36 * 35 34 33 32 31 30 29 * <- moved to weekly
backup downloads: 29 * 22 15 8 1 <- moved to a monthly
monthly backups: 1
Day 43:
Daily backups: 43 * 42 41 40 39 38 37 36 * <- moved to weekly
backup downloads: 36 29 * 22 15 8 <- deleted
monthly backups: 1
Day 50:
Daily backups: 50 * 49 48 47 46 45 44 43 * <- moved to weekly
backup downloads: 43 36 29 * 22 15 <- deleted
monthly backups: 1
Day 57:
Daily backups: 57 * 56 55 54 53 52 51 50 * <- moved to weekly
backup downloads: 50 43 36 29 * 22 <- deleted
monthly backups: 1
Day 64:
Daily backups: 64 * 63 62 61 60 59 58 57 * <- moved to weekly
backup downloads: 57 * 50 43 36 29 * <- moved to a monthly
monthly backup: 29 1
Day 92:
Daily backups: 92 * 91 90 89 88 87 86 85 * <- moved to weekly
backup downloads: 85 * 78 71 64 57 * <- moved to a monthly
monthly backups: 57 29 1
Day 120:
Daily backup: 120 * 119 118 117 116 115 114 113 * <- moved to weekly
backup downloads: 113 * 106 * 99 92 85 <- moved to a monthly
monthly backups: 85 57 29 1 <- removed

Backup program-with-history

Here is the implementation of the system with historical daily backups using rsync, in about 100 lines of Perl. This script can be found also online at http://people.masterwebnet.com/steven/files/backup-with-history.

1 | #! / Usr / bin / perl-w
|
3 | use strict;
4 | use CWD qw (abs_path);
5 | use POSIX;
6 | use Time:: Local;
|
8 | # --- config
9 | my $ Histories = [-7, 4, 3];
|
11 | # --- subs
12 | sub ESC (
13 | local $ _ = shift;
14 | s /'/'"'"'/ g;
15 | "'$_'";
16 |)
|
18 | # --- main
19 | @ ARGV == 2 or die "Usage: $ 0 \ n";
20 | my ($ src, $ dst) = @ ARGV;
21 | for ($ src, $ dst) (s !/$!!}
22 | (-d $ src) or die "Src must be an existing directory: $ src \ n";
23 | system "mkdir-p". ESC ( "$ dst / current");
24 | (-d "$ dst / current") or die "Failed to make creating $ dst / current \ n";
|
26 | print "Creating new backup $ src to $ dst / ... \ n";
27 | system "nice-n19 rsync-av - del - force"
28 |. "- link-dest"
29 |. ESC (abs_path ( "$ dst"). "/ current"). ""
30 |. ESC ( "$ src /"). ""
31 |. ESC ( "$ dst / .work /"). "\ n";
32 | warn "rsync command is not successful, you should check \ n" if $?;
|
34 | chdir ($ dst) or die "Can not chdir to $ dst: $! \ N";
35 | system "touch. Current.timestamp";
36 | my $ now = time;
37 | my @ st = stat ( ". Current.timestamp");
38 | my $ tstamp
39 | = POSIX:: strftime ( "% Y-% m-% d \ @% H:% M:% S +00", gmtime ($ st [9] | | $ now));
40 | rmdir "current" or rename "current", "Hist. $ Tstamp";
41 | rename ". Work", "current";
|
43 | print "Deleting backup history that has for too long ... \ n";
44 | for my $ level (1 .. @ $ Histories) (
45 | my $ is_highest_level = $ level == @ $ Histories;
46 | my $ prefix = "Hist". ($ Level == 1?: $ Level);
47 | my $ prefix_next_level = "Hist". ($ Level + 1);
48 | my $ n = $ Histories-> [$ level - 1];
49 | my $ moved = 0;
|
51 | if ($ n> 0) (
52 | print "Only $ n fruit store historical backups L $ level ... \ n";
53 | my @ f = reverse sort grep (! / \. Work $ /) glob "$ prefix .*";
54 | my $ any_tagged = (grep (/ t $ /) @ f)? 1: 0;
55 | for my $ f (@ f [$ n .. @ f - 1]) (
56 | my ($ st, $ tagged) = $ f = ~ /[^.]+ \ .(.+?)( t )?$/;
57 | my $ f2 = "$ prefix_next_level. $ St";
58 | if (! $ Is_highest_level
59 | & &! $ Moved
60 | & & ($ tagged | |! $ Any_tagged))
61 | (
62 | print "Moving the historical level backups: $ f -> $ f2 \ n";
63 | system "mv". ESC ($ f). "". ESC ($ f2);
64 | $ moved + +;
65 | if ($ f ne $ f [0]) (
66 | my $ e3 = ESC ($ f [0]);
67 | system "mv $ e3 $ (e3) t";
68 |)
69 |)
70 | else (
71 | print "Deleting backup history: $ f ... \ n";
72 | system "nice-n19 rm-rf". ESC ($ f);
73 |)
74 |)
75 |)
76 | else (
77 | $ n = - $ n;
78 | print "Just keep a backup history sd L $ level $ n day ... \ n";
79 | my @ f = reverse sort grep (! / \. Work $ /) glob "$ prefix .*";
80 | my $ any_tagged = (grep (/ t $ /) @ f)? 1: 0;
81 | for my $ f (@ f) (
82 | my ($ st, $ tagged) = $ f = ~ /[^.]+ \ .(.+?)( t )?$/;
83 | my $ f2 = "$ prefix_next_level. $ St";
84 | my $ t;
85 | $ st = ~ / (\ d \ d \ d \ d) - (\ d \ d) - (\ d \ d) \ @ (\ d \ d): (\ d \ d): (\ d \ d) \ +00 /;
86 | $ t = timegm ($ 6, $ 5, $ 4, $ 3, $ 2 - 1, $ 1) if $ 1;
87 | $ q & & $ t or do (
88 | print "History of backup formats: $ f, ignored \ n";
89 | next;
90 |);
91 | if ($ t> $ now) (
92 | print "History backups in the future? $ F, ignored \ n";
93 | next;
94 |)
95 | my $ delta = ($ now - $ t) / 86400;
96 | if ($ delta> $ n) (
97 | if (! $ Is_highest_level
98 | & &! $ Moved
99 | & & ($ tagged | |! $ Any_tagged))
100 | (
101 | print "Moving the historical level backups: $ f -> $ f2 \ n";
102 | system "mv". ESC ($ f). "". ESC ($ f2);
103 | $ moved + +;
104 | if ($ f ne $ f [0]) (
105 | my $ e3 = ESC ($ f [0]);
106 | system "mv $ e3 $ (e3) t";
107 |)
108 |)
109 | else (
110 | print "Deleting backup history: $ f ... \ n";
111 | system "nice-n19 rm-rf". ESC ($ f);
112 |)
113 |)
114 |)
115 |)
116 |)
|
118 |

How to use this script:

$ Backup-with-history DIR DIRBACKUP

DIR is the directory you want backed up, eg / home / steven. DIRBACKUP is the desired backup location, eg: / backup / home-steven. Better / backup is on a different hard drive, because the local backup purposes is to avoid loss of data due to hard drive damage. Backup process is complete, the script will form DIRBACKUP directory / current / which contains the latest backup, and a series DIRBACKUP directory / Hist .*, hist2 .*, and which contains hist3 history .* daily backups, weekly, monthly.

To perform a backup process itself is essentially the line 27-31, which relies on rsync. Rsync is going to handle the transfer and synchronization with directory structure of each file metadata (permissions, ownership, date, etc.). With the - link-dest, rsync will also compare the data with the last backup (current /) and do hardlinking if possible. The rest of the script is handling most of the rotation of backup history.

This script is simple. You can add that can be configured (eg: option - exclude rsync, etc.). Good luck!