Abstract:
The present invention discloses a method and an apparatus for automatically backing up data, relates to the field of communications technologies, and is used to solve a problem that a mobile phone is damaged due to falling down of the mobile phone, and consequently data of a user is lost. The method provided in the present invention includes: detecting whether a terminal is falling down; and if it is detected that the terminal is falling down, triggering a data backup operation and backing up data that needs to be backed up in the terminal. The present invention is applicable to the field of communications technologies, and is used to back up data of a user.

Description:
CROSS-REFERENCE TO RELATED APPLICATIONS 
       [0001]    This application claims priority to Chinese Patent Application No. 201210121332.6, filed on Apr. 23, 2012, which is hereby incorporated by reference in its entirety. 
       FIELD OF THE INVENTION 
       [0002]    The present invention relates to the field of communications technologies, and in particular, to a method and an apparatus for automatically backing up data. 
       BACKGROUND OF THE INVENTION 
       [0003]    With the popularity of smart mobile phones, mobile phones play an increasingly important role in daily life. Mobile phones are not only communication tools but also storage and entertainment integration devices. In addition to communication functions such as daily voice calls and Internet browsing, a user can also store some important data in a mobile phone for the convenience of usage. For example, a user can store, in a mobile phone, information such as an E-mail and an address of a contact and configuration information of the current mobile phone. In order to ensure the information security of important data, currently many manufactures of manufacturing smart mobile phones provide a cloud-service solution, in which after it is monitored that a user triggers a data backup function, data in a mobile phone of the user can be associated and synchronized with data of a backup service server end, so that important data in the mobile phone of the user is backed up. 
         [0004]    However, the prior art has at least the following problem: At the time of backing up important data, a data backup service can be finished only if a user triggers a data backup function actively. If the user does not back up data in time and actively, when a mobile phone is damaged due to falling down of the mobile phone, as a result, the data of the user may be lost. 
       SUMMARY OF THE INVENTION 
       [0005]    Embodiments of the present invention provide a method and an apparatus for automatically backing up data, so that when a user terminal is falling down, data can be automatically backed up, thereby ensuring the security of data of a user. 
         [0006]    To achieve the foregoing objective, the embodiments of the present invention adopt the following technical solutions. 
         [0007]    In one aspect, an embodiment of the present invention provides a method for automatically backing up data, where the method includes: 
         [0008]    detecting whether a terminal is falling down; and 
         [0009]    if it is detected that the terminal is falling down, triggering a data backup operation and backing up data that needs to be backed up in the terminal. 
         [0010]    In another aspect, an embodiment of the present invention further provides an apparatus for automatically backing up data, where the apparatus includes: 
         [0011]    a detecting unit, configured to detect whether a terminal is falling down; and 
         [0012]    a backup unit, configured to: when the detecting unit detects that the terminal is falling down, trigger a data backup operation and back up data that needs to be backed up in the terminal. 
         [0013]    With the method and the apparatus for automatically backing up data provided in the embodiments of the present invention, when a terminal is falling down, data of a user can be actively backed up, thereby ensuring the security of the data of the user. 
     
    
     
       BRIEF DESCRIPTION OF THE DRAWINGS 
         [0014]    To describe the technical solutions in the embodiments of the present invention or in the prior art more clearly, the accompanying drawings required for describing the embodiments or the prior art are briefly introduced in the following. Apparently, the accompanying drawings in the following description show merely some embodiments of the present invention, and persons of ordinary skill in the art may still derive other drawings from these accompanying drawings without creative efforts. 
           [0015]      FIG. 1  is a schematic flow chart of a method for automatically backing up data according to Embodiment 1 of the present invention; 
           [0016]      FIG. 2  is a schematic flow chart of a method for automatically backing up data according to Embodiment 2 of the present invention; 
           [0017]      FIG. 3  is a schematic diagram of a coordinate system used by an acceleration sensor in a terminal according to Embodiment 2 of the present invention; 
           [0018]      FIG. 4  is a schematic flow chart of a method for automatically backing up data according to Embodiment 3 of the present invention; and 
           [0019]      FIG. 5  to  FIG. 8  are schematic structural diagrams of an apparatus for automatically backing up data according to Embodiment 4 of the present invention. 
       
    
    
     DETAILED DESCRIPTION OF THE EMBODIMENTS 
       [0020]    The technical solutions in the embodiments of the present invention are described clearly and completely in the following with reference to the accompanying drawings in the embodiments of the present invention. Apparently, the embodiments to be described are merely a part rather than all of the embodiments of the present invention. All other embodiments obtained by persons of ordinary skill in the art based on the embodiments of the present invention without creative efforts shall fall within the protection scope of the present invention. 
       Embodiment 1 
       [0021]    An embodiment of the present invention provides a method for automatically backing up data, and as shown in  FIG. 1 , the method includes: 
         [0022]      101 : Detect whether a terminal is falling down. 
         [0023]    The terminal in this embodiment is a terminal device that has an acceleration sensor, which includes but is not limited to a mobile phone and a tablet computer that have an acceleration sensor. The acceleration sensor can sense an acting force exerted on the terminal device. When a terminal is in a free falling state, an outside acting force exerted on the terminal in a gravitational direction is 0, so that whether the terminal is falling down can be determined through an acceleration sensor. 
         [0024]    It should be noted that, because of the wide popularity of the Android (Android) system and a feature of open source design of the system, the terminal in this embodiment is preferably a terminal device that adopts the Android system, which is not limited herein. 
         [0025]      102 : If it is detected that the terminal is falling down, trigger a data backup operation and back up data that needs to be backed up in the terminal. 
         [0026]    With the method for automatically backing up data provided in this embodiment of the present invention, when a terminal is falling down, a data backup service can be actively triggered to back up data of a user, thereby ensuring the security of the data of the user. 
       Embodiment 2 
       [0027]    An embodiment of the present invention provides a method for automatically backing up data, and as shown in  FIG. 2 , the method includes: 
         [0028]      201 : A Push Agent (push agent) monitors, in real time through an acceleration sensor, an acting force exerted on a terminal. 
         [0029]    The Push Agent is a background running program applied to the terminal, and can actively trigger a data backup function when a preset triggering condition is met, so as to send data that needs to be backed up to a backup service server for backup. The terminal in this embodiment is a terminal device that has an acceleration sensor, which includes but is not limited to a mobile phone and a tablet computer that have an acceleration sensor. The acceleration sensor can sense an acting force exerted on the terminal device. 
         [0030]    It should be noted that, because of the popularity of the Android system and a feature of open source design of the system, the terminal in this embodiment is preferably a terminal device that adopts the Android system, which is not limited herein. The Android system provides an API (Application Programming Interface, application programming interface) of an acceleration sensor for an application program in the terminal to invoke. Specifically, values (array) in a SensorEvent (acceleration sensor event) object provided by the API of the acceleration sensor may be used as a determination value of an acceleration in a vertical direction. 
         [0031]    Specifically, as shown in  FIG. 3 , an acceleration sensor in an Android mobile phone can monitor, in real time, acting forces exerted on the mobile phone in directions of axis X, axis Y, and axis Z. In  FIG. 3 , a scenario where a mobile phone is horizontally placed on a horizontal plane with the screen upward is taken as an example for description. Axis X and axis Y are in horizontal directions of two adjacent side edges of the mobile phone. Numerical values of axis X and axis Y are used for representing acting forces that are exerted on the mobile phone in the horizontal directions (namely, directions pointed by axis X and axis Y). Axis Z is in a direction that is perpendicular to the mobile phone screen, and a numerical value (hereinafter referred to as a value Z) of axis Z is used for representing an acting force that is exerted on the mobile phone in a gravitational direction. The values are an array formed by numerical values of axes (namely, axis X, axis Y, and axis Z) in a three-dimensional space. 
         [0032]      202 : When the Push Agent monitors that an acting force exerted on the terminal in a gravitational direction reaches a preset threshold, determine that the terminal is in a falling state. 
         [0033]    It should be noted that, this embodiment of the present invention is applied to a scenario where a terminal is falling down freely (such as a scenario where a mobile phone slips off from the hand when a user is in a call), that is, a falling trajectory of the terminal is vertically downward along the gravitational direction, and a posture of the mobile phone remains unchanged in a falling process. In this embodiment of the present invention, the Push Agent is specifically configured to monitor a value Z measured by the acceleration sensor. When it is monitored that the value Z reaches a preset threshold, it is determined that the terminal is in a falling state. 
         [0034]    In this embodiment of the present invention, the preset threshold is preset according to an instruction of a user and is used to indicate sensitivity of triggering a data backup service. The larger the threshold is, the lower the sensitivity of triggering a data backup service is; and the smaller the threshold is, the higher the sensitivity of triggering a data backup service is. 
         [0035]    It should be noted that, the foregoing preset threshold is theoretically most accurate when it is set to 0. However, for the consideration of factors, such as aging of a terminal and an error of a measurement value of an acceleration sensor, in order to fully ensure the security of data of a user, the user may set the preset threshold according to a demand of the user, so that when a force exerted on the terminal in the gravitational direction is close to 0, it is determined that the terminal is falling down. 
         [0036]      203 : When it is monitored that the terminal is falling down, actively trigger a data backup function, and send a TLS (Transport Layer Security, transport layer security) long connection request to a backup channel server, where the request is used to instruct the backup channel server to establish a data transmission channel for the current terminal. The TLS long connection request may carry authentication information of the terminal, where the authentication information is used by the data transmission channel to perform authentication on the terminal and a data transmission channel is established for the terminal after the authentication succeeds. 
         [0037]    The backup channel server in this embodiment is configured to establish the data transmission channel for the terminal, so that the terminal uploads data to the backup service server for backup. The backup channel server includes at least a Push Server (push server), an Auth Server (Authenticate Server, authentication server), and a CRS (Clouder Router Server, cloud router server). The Push Server is configured to perform data transmission with the Push Agent; the Auth Server is configured to perform authentication on the terminal, so as to determine whether the terminal has data backup permission; and the CRS provide an HTTP (Hyper Text Transport Protocol, hyper text transport protocol) interface for the backup service server, where the HTTP interface is used to perform data transmission with the backup service server, where an internal long connection may be established between the Push Server and the CRS through a TCP (Transmission Control Protocol, transmission control protocol). 
         [0038]      204 : The backup channel server acquires the authentication information of the terminal, performs authentication on the terminal, and establishes a data transmission channel for the terminal after the authentication succeeds. 
         [0039]      205 : The Push Agent uploads, through the data transmission channel established by the backup channel server for the terminal, data that needs to be backed up to a backup Service server, so as to finish a data backup service. The backup service server is configured to store backup data that is sent by the terminal, so as to implement association and synchronization of the backup data with the terminal. 
         [0040]    It should be noted that, in this embodiment of the present invention, the data that needs to be backed up may be data that needs to be backed up by default in the terminal, and may also be data that is defined, according to an instruction of a user, as data that needs to be backed up, which is not limited herein. 
         [0041]    With the method for automatically backing up data provided in this embodiment of the present invention, when a terminal is falling down freely, a data backup function can be automatically triggered to back up data of a user, thereby ensuring the security of the data of the user. 
         [0042]    In the following, an extended application of the technical solution in the present invention is provided. 
         [0043]    When an after-sales department of a terminal manufacturer repairs a damaged terminal device, the terminal usually needs to be detected, so as to determine whether the terminal is damaged artificially. Currently, a process of detecting whether the terminal is damaged artificially is relatively travail. 
         [0044]    According to the method provided in this embodiment of the present invention, if a Push Agent monitors that a terminal is falling down, falling information of the terminal can be sent to an after-sales server of the terminal, so as to indicate that a falling behavior happens to the terminal at a certain time. When repairing a damaged terminal device, an after-sales department can query an after-sales server to determine whether a falling behavior happens to the terminal, thereby conveniently determining whether the terminal is damaged artificially. 
       Embodiment 3 
       [0045]    An embodiment of the present invention provides a method for automatically backing up data, and as shown in  FIG. 4 , the method includes: 
         [0046]      401 : A Push Agent monitors, in real time through an acceleration sensor, an acting force exerted on a terminal. 
         [0047]    The Push Agent is a background running program applied to the terminal, and can actively trigger a data backup function when a preset triggering condition is met, so as to send data that needs to be backed up to a backup service server for backup. The terminal in this embodiment is a terminal device that has an acceleration sensor, which includes but is not limited to a mobile phone and a tablet computer that have an acceleration sensor. The acceleration sensor can sense an acting force exerted on the terminal device. 
         [0048]    It should be noted that, because of the popularity of the Android system and a feature of open source design of the system, the terminal in this embodiment is preferably a terminal device that adopts the Android system, which is not limited herein. The Android system provides an API of an acceleration sensor for an application program in the terminal to invoke. Specifically, values in a SensorEvent object provided by the API of the acceleration sensor may be used as a determination value of an acceleration in a vertical direction. 
         [0049]      402 : The Push Agent monitors a current posture of the terminal through a gyroscope. 
         [0050]    The gyroscope can detect the current posture of the terminal in a space, that is, can determine whether the terminal is horizontally placed or slantwise placed. 
         [0051]      403 : In conjunction with the current posture of the terminal, the Push Agent determines, according to the acceleration sensor, an acting force exerted on the terminal in a horizontal direction and an acting force exerted on the terminal in a gravitational direction. 
         [0052]    It should be noted that, the acting force that is exerted on the terminal and sensed by the acceleration sensor is merely relative to the terminal. To facilitate understanding, as shown in  FIG. 3 , the acceleration sensor can determine magnitudes and directions of acting forces exerted on the terminal on axis X, axis Y, and axis Z. It should be emphasized that, in  FIG. 3 , a coordinate system formed by axis X, axis Y, and axis Z is fixed relative to the terminal, directions of axis X, axis Y, and axis Z change with a change of a posture of the terminal. 
         [0053]    In this embodiment, the Push Agent monitors, through the acceleration sensor, the acting force exerted on the terminal; meanwhile, in conjunction with the current posture of the terminal, where the current posture of the terminal is monitored through the gyroscope, the Push Agent can determine the acting forces exerted on the terminal in the horizontal direction and in the gravitational direction. 
         [0054]      404 : When it is monitored that the acting force exerted on the terminal in the horizontal direction is not 0, send a TLS long connection request to a backup channel server, where the request is used to instruct the backup channel server to establish a data transmission channel for the current terminal. The TLS long connection request may carry authentication information of the terminal, where the authentication information is used by the data transmission channel to perform authentication on the terminal and a data transmission channel is established for the terminal after the authentication succeeds. 
         [0055]    The backup channel server in this embodiment is configured to establish a data transmission channel for the terminal, so that the terminal uploads data to the backup service server for backup. The backup channel server includes at least a Push Server, an Auth Server, and a CRS. Reference is made to Embodiment 2 for specific functions of the Push Server, the Auth Server, and the CRS, which are not repeated herein. 
         [0056]      405 : The backup channel server acquires the authentication information of the terminal, performs authentication on the terminal, and establishes a data transmission channel for the terminal after the authentication succeeds. 
         [0057]      406 : When it is monitored that the acting force exerted on the terminal in the gravitational direction reaches a preset threshold, determine that the terminal is in a falling state. 
         [0058]    In this embodiment of the present invention, the preset threshold is preset according to an instruction of a user and is used to indicate sensitivity of triggering a data backup service. The larger the threshold is, the lower the sensitivity of triggering a data backup service is; and the smaller the threshold is, the higher the sensitivity of triggering a data backup service is. 
         [0059]    It should be noted that, the foregoing preset threshold is theoretically most accurate when it is set to 0. However, for the consideration of factors, such as aging of a terminal and an error of a measurement value of an acceleration sensor, in order to fully ensure the security of data of a user, the user may set the preset threshold according to a demand of the user, so that when a force exerted on the terminal in the gravitational direction is close to 0, it is determined that the terminal is falling down. 
         [0060]      407 : The Push Agent uploads, through the data transmission channel established in advance, data that needs to be backed up to the backup service server, so as to finish data backup. The backup service server is configured to store backup data that is sent by the terminal, so as to implement association and synchronization of the backup data with the terminal. 
         [0061]    In this embodiment of the present invention, the data that needs to be backed up may be data that needs to be backed up by default in the terminal, and may also be data that is defined, according to an instruction of a user, as data that needs to be backed up, which is not limited herein. 
         [0062]    It should be noted that, this embodiment is applied to a scenario where a terminal is falling down due to an outside force, such as, a scenario where a terminal placed on a desktop flies out after an outside force is exerted on the terminal. Specifically, when the terminal placed on the desktop slips off due to the outside force, according to steps  404  and  405 , in a sliding process of the terminal, a data transmission channel can be established for the terminal; and when the terminal is falling down, a data backup operation can be rapidly finished through the data transmission channel established in advance. 
         [0063]    With the method for automatically backing up data provided in this embodiment of the present invention, when an outside force is exerted on a terminal, whether the terminal is falling down can be determined in advance, and a data transmission channel is established in advance; and when it is determined that the terminal is falling down, a data backup service is finished through the data transmission channel established in advance, thereby ensuring the security of data of a user. 
       Embodiment 4 
       [0064]    An embodiment of the present invention provides an apparatus for automatically backing up data, which can implement the foregoing method embodiments. As shown in  FIG. 5 , the apparatus includes: 
         [0065]    a detecting unit  51 , configured to detect whether a terminal is falling down; and 
         [0066]    a backup unit  52 , configured to: when the detecting unit detects that the terminal is falling down, trigger a data backup operation and back up data that needs to be backed up in the terminal. 
         [0067]    Further, as shown in  FIG. 6 , the detecting unit  51  includes a first monitoring module  511  and a first determining module  512 , and the backup unit  52  includes an authentication module  521  and a data backup module  522 . 
         [0068]    The first monitoring module  511  is configured to monitor, in real time through an acceleration sensor, an acting force exerted on the terminal. 
         [0069]    The first determining module  512  is configured to: when it is monitored that an acting force exerted on the terminal in a gravitational direction reaches a preset threshold, determine that the terminal is in a falling state. 
         [0070]    The authentication module  521  is configured to send authentication information to a backup channel server, so that the backup channel server performs authentication on the terminal and establishes a data transmission channel for the terminal after the authentication succeeds. 
         [0071]    The data backup module  522  is configured to upload, through the data transmission channel, data that needs to be backed up to a backup service server, so as to finish a data backup service. The backup service server is configured to store backup data that is sent by the terminal, so as to implement association and synchronization of the backup data with the terminal. 
         [0072]    Further, as shown in  FIG. 7 , the apparatus further includes a gyroscope  53 . The detecting unit  51  includes a second detecting module  513  and a second determining module  514 , and the backup unit includes an early-warning module  523 . 
         [0073]    The gyroscope  53  is configured to monitor a current posture of the terminal. 
         [0074]    The second detecting module  513  is configured to monitor, in real time through the acceleration sensor, the acting force exerted on the terminal, and in conjunction with the current posture of the terminal, determine, according to the acceleration sensor, an acting force exerted on the terminal in a horizontal direction and an acting force exerted on the terminal in the gravitational direction. 
         [0075]    The second determining module  514  is configured to: when the acting force exerted on the terminal in the gravitational direction reaches a preset threshold, determine that the terminal is in a falling state. 
         [0076]    The early-warning module  523  is configured to: when the acting force exerted on the terminal in the horizontal direction is not 0, trigger a data backup operation and send authentication information to a backup channel server, so that the backup channel server performs authentication on the terminal and establishes a data transmission channel for the terminal after the authentication succeeds. 
         [0077]    The backup unit  52  is specifically configured to: when it is determined that the terminal is in a falling state, upload, through the data transmission channel established in advance, data that needs to be backed up to a backup service server, so as to finish data backup. 
         [0078]    Further, as shown in  FIG. 8 , the apparatus further includes: 
         [0079]    a threshold setting unit  54 , configured to preset a preset threshold, where the preset threshold is used to indicate sensitivity of triggering a data backup service. The larger the threshold is, the lower the sensitivity of triggering a data backup service is; and the smaller the threshold is, the higher the sensitivity of triggering a data backup service is. 
         [0080]    With the apparatus for automatically backing up data provided in this embodiment of the present invention, when a terminal is falling down, a data backup function can be actively triggered to back up data of a user, thereby ensuring the security of the data of the user. 
         [0081]    Through the foregoing description of the embodiments, persons skilled in the art may clearly understand that the present invention may be implemented by software plus necessary universal hardware, and definitely may also be implemented by hardware, but in many cases, the software implementation is preferred. Based on such an understanding, the technical solutions of the present invention essentially, or the part contributing to the prior art may be implemented in the form of a software product. The computer software product is stored in a readable storage medium, for example, a floppy disk, a hard disk, or an optical disk of a computer, and includes several instructions for instructing a computer device (which may be a personal computer, a server, or a network device) to perform the methods described in the embodiments of the present invention. 
         [0082]    The foregoing descriptions are merely specific embodiments of the present invention, but are not intended to limit the protection scope of the present invention. Any variation or replacement readily figured out by persons skilled in the art within the technical scope disclosed in the present invention shall all fall within the protection scope of the present invention. Therefore, the protection scope of the present invention shall be subject to the protection scope of the claims.